-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cannot expand variable in comment #1311
Comments
I think | <!-- build:js(adminapp.src) #{cloudfront}js/testapp.min.js--> should work. |
Indeed, jade comments are deliberately pure comments, to allow people to type whatever they like in them. |
The comments are not displayed in the browser, but it the still full-fledged DOM-nodes! //= BUILD: version Much better than: !='<!-- BUILD: ' + version + '-->' Why not? |
Because generated comments are currently second class citizens. Comments are designed for commenting rather than anything else. |
Template engines are designed to generate HTML code. function getCommentNodes(node) {
var treeWalker = document.createTreeWalker(node,
NodeFilter.SHOW_COMMENT, null, false),
comments = [];
while (treeWalker.nextNode()) {
comments.push(treeWalker.currentNode);
}
return comments;
}
// Create a comment
var comment = document.createComment('foo');
document.body.appendChild(comment);
// Get all comments
var comments = getCommentNodes(document.body);
// Iterate over comments
comments.forEach(function (comment) {
console.log(comment.data); // foo
}); I know a lot of template engines that support my point of view: HAML:/
= variable
/
#{variable} EJS <!-- <%= variable %> --> Dust<--! {variable} --> Mustache, Handlebars, Hogan<!-- {{variable}} --> Fest<fest:comment>
<fest:value>variable </fest:value>
</fest:comment> I can not even remember any template engines that does not support interpolation comments. Only Jade? |
+1 @monolithed |
why was this closed without resolution |
I have to agree. I use gulp-useref. For cache busting I would love to be able to:
|
Because you can just do: <!--build:js /js/app.min.js?v=#{version}-->
<!--endbuild--> If you really need that and it's perfectly valid jade. It's also much better to do it this way if you're using this for builds since a lot of build tools that use comments tend to be really sensitive about precise spacing etc. and this gives you total control. |
I searched for the variable expanding at comments for the same reason and I found that issue. I tried the solution with writting the comment directly in html:
The problem is, that I have something above the block:
After compiling pug the result is:
The problem is that usemin removes all before build:css and I lose the meta tag (I use already the conig I can add |
Im also looking for a solution for this as well. Obviously this isnt a very important issue, just more of an annoyance when you're going for some well-formatted source code, then this one thing throws it off. |
Ended up with this.
|
Hi,
I'd like to have a variable expanded inside a comment for inserting a cloudfront server in a useminPrepare block:
Just outputs the #{} verbatim:
<!-- build:js(adminapp.src) #{cloudfront}js/testapp.min.js-->
nearly works, but the closing comments ends up on a new line, which confuses useminPrepare:
Is there any way around this?
The text was updated successfully, but these errors were encountered: