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

Ability to change template delimiters? #45

Closed
cemckinley opened this Issue Dec 19, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@cemckinley

cemckinley commented Dec 19, 2013

I think it would be really useful to be able to change the delimiters used by lodash within the this.template() method in a generator. A generator I'm currently working on has client side underscore templates in the output files, as well as a Gruntfile that is trying to use underscore templates for config variables - both are causing collisions. I've tried a solution like this to change the delimiters to <: :>, within the generator construction function:

    this._.templateSettings.interpolate = /<\:(.+?)\:>/g;
    this._.templateSettings.escape = /<\:-(.*?)\:>/g;
    this._.templateSettings.evaluate = /<\:=(.*?)\:>/g;

mentioned in this issue: yeoman/yeoman#1235, but that doesn't appear to work, none of the updated delimiter/tags are getting parsed.

I realize I can use my own instance of lodash, or some other templating engine, but it would be really great to be able to use the this.template() method, since it's so much more convenient/useful for generating files from templates...

Perhaps I'm missing something?

@cemckinley

This comment has been minimized.

Show comment
Hide comment
@cemckinley

cemckinley Dec 20, 2013

A friend tipped me off to using a double percent in the opening template tag, like <%%= someVar %> which appears to work great for escaping tags during the generator processing. I can't find it in the docs anywhere? Still, may be useful to be able to change template delimiters.

cemckinley commented Dec 20, 2013

A friend tipped me off to using a double percent in the opening template tag, like <%%= someVar %> which appears to work great for escaping tags during the generator processing. I can't find it in the docs anywhere? Still, may be useful to be able to change template delimiters.

@ahmednuaman

This comment has been minimized.

Show comment
Hide comment
@ahmednuaman

ahmednuaman Jan 14, 2014

Thank you! The double %% work perfectly 👍

ahmednuaman commented Jan 14, 2014

Thank you! The double %% work perfectly 👍

@hamsterbacke23

This comment has been minimized.

Show comment
Hide comment
@hamsterbacke23

hamsterbacke23 Jan 22, 2014

Thanks that helped me too

hamsterbacke23 commented Jan 22, 2014

Thanks that helped me too

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