-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
Added funtionality to change template delimiters in the template engine. #489
Conversation
Can you fix the build errors? |
Ah! Yes. Sorry about that. It should be fixed now. |
For anyone coming across this in 2015, the use of engine.options no longer works. To change the delimiters now, you pass a templateSettings object as the 4th argument to copyTpl as in:
Which allows |
@sambaker - Thank you! That was driving me batty all weekend. |
@sambaker - Thank you as well... after much searching, your post above did it for me... but i did have to alter the regex in order for it to work... I had to escape the this.fs.copyTpl(this.templatePath('yourtemplate'), this.destinationPath('yourDestFile'), this, {
escape: /<\$-([\s\S]+?)\$>/g,
evaluate: /<\$([\s\S]+?)\$>/g,
interpolate: /<\$=([\s\S]+?)\$>/g
}); For any others: Yeoman documentation points to ejs.co for information on the templating engine... but none of these options are documented there... It does, however, mention the (FYI: my use case: I was adding some file paths to a |
@purtuga this mean you're not using the latest version ;) Our documentation follow our latest release, it looks like you're still on 0.19 |
I thought I was running the latest, since I installed yeoman/generator-generator for the first time last week. But I'll check and report back. Thanks for letting me know. Paul |
@SBoudrias - Just checked...yes.. still on 0.19.2. Will upgrade. Thanks. |
Just wanted to report back... After upgrading to v0.20.2 of generator-generator, the this.fs.copyTpl(this.templatePath('yourtemplate'), this.destinationPath('yourDestFile'), this, {
delimiter: "$"
}); |
Thanks @purtuga, I was confused trying to get the deprecated syntax to work. |
yeoman/generator-generator#45 and yeoman/yeoman#1235 talk about ways to pass options to lodash to change the template delimiters. However the template engine in yeoman does some detecting and has the
%%
escaping built in. If I try to template a file that doesn't have any<%``%>
tags in the file it won't get templated.This pull request adds the ability to provide options to the engine to customize the detection and escaping. For example the following configuration could be used to escape with
{{``}}
delimiters and escape a{{{
to{{
.I also added tests that should cover this added configuration and would illustrate the issue without these changes.