Reputation: 37819
I want to programatically set the content of a comment. But this doesn't work:
p Hello
// = 'Generated at ' + date
It just outputs this:
<p>Hello</p>
<!-- = 'Generated at ' + date -->
How can I output a comment with something dynamic in it? I can't see anything in the docs about this.
Upvotes: 1
Views: 326
Reputation: 8540
Interpolation seems to work in block comments:
- const date = new Date()
// Generated at #{date}
//
Generated at #{date}
Output (using Pug 2.0.4):
<!-- Generated at #{date}-->
<!--Generated at Sun Jan 24 2021 20:30:16 GMT+0200 (Eastern European Standard Time)-->
Upvotes: 0
Reputation:
Unfortunately for you in this case, Jade does not evaluate the comment's value. You can hack around this by doing:
!='<!-- Generated at ' + date + '-->'
Upvotes: 4