Skip to content

Conversation

@mnelson
Copy link

@mnelson mnelson commented Jan 15, 2014

Raw interpolation is defaulted to {{{= content }}}. I'm open to other delimiters but chose this to be consistent with mustache / handlebars and still consistent with the interpolation syntax used in sudo.

This is useful if you have a view which pre-processes content and generates html.

Example:

// in your view

urlRegex: /\(?\b(https?://|www.)([-A-Za-z0-9+(&)@#(/)%?=~_()|!:,.;]*[-A-Za-z0-9+(&)@#(/)%=~_()|])/g,

render: function render() {
  this.model.set('linkedContent', this.linkify(this.model.get('content')));
  this.$el.html(template(this.model.data));
},

linkify: function linkify(content) {
  return sudo.escape(content).replace(this.urlRegex, '<a class="inline-link" href="/redirect?url=$1$2" target="_blank">$1$2</a>');
}
<div>
  <h2>{{=data.title}}</h2>
  <p>{{{=data.linkedContent}}}</p>
</div>

@mnelson
Copy link
Author

mnelson commented Jan 15, 2014

If this is accepted into master I'll update the wiki documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants