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

"{{" without whitespace after is not treated as code #135

Closed
adamrogas opened this issue Dec 27, 2014 · 3 comments
Closed

"{{" without whitespace after is not treated as code #135

adamrogas opened this issue Dec 27, 2014 · 3 comments

Comments

@adamrogas
Copy link

The issue is that when you strip whitespace on a file that has line style comments

i.e. //commnted text

the comments will almost always cause unintended side effects, like client side javascript errors

@glukki
Copy link

glukki commented Jan 19, 2015

Block comments FTW!
/* whatever */

@ouadi
Copy link

ouadi commented Aug 20, 2015

The above solution doesn't work when dot.templateSettings.strip is set to true.

The code:

dot.templateSettings.strip          = true;
dot.templateSettings.append         = false;
dot.templateSettings.selfcontained  = false;
var template = '' +
    '{{/* Some comment*/}}\n' +
    'Hello\n' +
    ';';
var compiled = dot.template(template, undefined, {});
console.log(compiled({}));

produces:

{{}}Hello

Note: I have posted this same comment on #165.

@epoberezkin
Copy link
Collaborator

epoberezkin commented Oct 30, 2016

@ouadi You need to use {{ /* Some comment*/ }}. There may be a place for doT comments that are not included in the compiled function, although I am not sure about the value of such feature.

Probably adding to doT 101 is a good idea #205

@epoberezkin epoberezkin reopened this Oct 30, 2016
@epoberezkin epoberezkin changed the title remove line style comments prior to executing the whitespace strip "{{" without whitespace after is not treated as code. Oct 30, 2016
@epoberezkin epoberezkin changed the title "{{" without whitespace after is not treated as code. "{{" without whitespace after is not treated as code Oct 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants