Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for raw content interpolation #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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.

None yet

1 participant