googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

Allow users to override mustache syntax for conflicting template systems #192

Open ebidel opened 9 years ago

ebidel commented 9 years ago

AFAICT, there's no way for users to override the mustaches with another token, say {{{}}}. This comes up where {{}} conflicts with other templating systems.

From http://stackoverflow.com/questions/26173604/using-polymer-templates-in-tumblr-themes

addyosmani commented 9 years ago

In Underscore/Lodash, the template settings allow you to define an interpolate regex to match expressions, effectively supporting customization similar to the above. Are you looking for that kind of power, or just the ability to change the token deliminators outright (e.g tokenStart='[[', tokenEnd=']]')? Either way, I think this is worth supporting as it's likely to come up increasingly over the next year or two.

IIRC, Underscore just does:

// e.g for {{-
_.templateSettings.escape = /\{\{-(.*?)\}\}/g
compiled = _.template("Escaped: {{- value }}\nNot escaped: {{ value }}")