Open nknapp opened 9 years ago
Looks like it's producing exactly what would be expected. {{! abc }}
is a handlebars comment. Which is removed from the rendered result. http://handlebarsjs.com/#comments
But why is the helper-output treated as handlebars-template?
try doing verb --set stripComments=false
or verb stripComments=false
https://github.com/verbose/verb/blob/master/lib/plugins/comments.js.
since lodash doesn't have any kind of comments feature, it was implemented as an extra feature. It doesn't look like I wired up the config store to be used for options on that plugin though, so the flag will need to be set every time you run verb until that's implemented. All we need to do is add something like this inside the plugin:
var stripComments = this.config.get('stripComments');
then use whatever that returns if it's not undefined
actually I think it should be disabled by default.... I'll mark this as a bug in the meantime since it's causing unexpected results and it's not clear to the user what's happening
Ah, that explains it. Maybe comment-stripping should occur before parsing the template, so that helper output is not stripped. Having comments is fine, but I think the output of helpers should not be modified.
Maybe comment-stripping should occur before parsing the template, so that helper output is not stripped.
probably, let's give that a shot. I don't think there was a specific reason I chose postRender
, I just couldn't think of a reason not to at the time...
but I think the output of helpers should not be modified.
completely agree, this is why I marked it a bug. I would have never occurred to me that someone would create a lodash helper to generate handlebars comments lol. don't take that as a slam though! I'm all for using whatever techniques are necessary to get a job done!
Maybe (haven't tried it yet!), it is possible to make comments in lodash-templates like
{%=''/* this is a comment */ %}
or something like that.
I can't understand what is the logic. In both sides there's no logic for me - in template engine (no matter what it is) it would be skipped, also in verb. Why someone would want to preserve template comment, when template engine do nothing with them? But okey if they are preserved, where you will use them, for what, when and why? I mean.. if you want to use them just for hinting you always can use html comments and it is guaranteed that they won't be displayed, then the job won't be related to verb and template engine.
I dont know, maybe missing the point. I think it's not a bug.
PS: And okey, if you disable "stripping comments" they will stay after verb finishes rendering. So.. I guess you want to run one more rendering (with another template engine) over that output.. why? why not use verb, it is powerful and more than generator, more than documentator and etc.
@tunnckoCore My problem is that the documentation of comment-patterns concerning Handlebars templates is wrong. The multilineComment
-part should be
multiLineComment: [{
start: '<!--',
middle: '',
end: '-->'
}, {
start: '{{!--',
middle: '',
end: '--}}',
apidoc: true
}, {
start: '{{!',
middle: '',
end: '}}'
}]
I just noticed that some of the entries of the
comment-patterns
-doc are not displayed correctly: the Mustache and Handlebars multiline-patterns are disappearing. I have cut the problem down to these two files.verb.md
:verbfile.js
The output is not, as I would have expected:
but
(see verb-tests). I would like to know why. Is this a bug?