Skip to content

Instantly share code, notes, and snippets.

@dana-ross
Created October 19, 2015 21:06
Show Gist options
  • Save dana-ross/5330bbc7ca22a2141bc0 to your computer and use it in GitHub Desktop.
Save dana-ross/5330bbc7ca22a2141bc0 to your computer and use it in GitHub Desktop.
Use underscore.js template engine with Mustache-style template tags (including escaping) instead of concatenation
_.template(
'[{{{ shortcodeString }}} url="{{{ url }}}" width="{{{ width }}}" height="{{{ height }}}"]',
{'shortcodeString': 'test',
'url': 'http://example.com',
'width': '100',
'height': '200'
}, {
interpolate: /\{\{([\s\S]+?)\}\}/g,
escape: /\{\{\{([\s\S]+?)\}\}\}/g}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment