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

Ability to change template delimiters? #45

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

Ability to change template delimiters? #45

cemckinley opened this issue Dec 19, 2013 · 3 comments

Comments

@cemckinley
Copy link

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
Copy link
Author

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
Copy link

Thank you! The double %% work perfectly 👍

@hamsterbacke23
Copy link

Thanks that helped me too

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

No branches or pull requests

4 participants