Reputation: 7741
Is there a way to put comments (single and multiline) in ECO templates such that they do not appear in the rendered output?
For example, Django templates let you do this on a single line:
{# greeting #}hello
or on multiple lines:
<p>Rendered text with {{ pub_date|date:"c" }}</p>
{% comment %}
<p>Commented out text with {{ create_date|date:"c" }}</p>
{% endcomment %}
Upvotes: 2
Views: 915
Reputation: 1282
There is a special tag for commenting, namely, <%# %>
Example:
<%# This is a single line comment %>
Upvotes: 2
Reputation: 3441
Effectively everything inside the <% %>
is coffeescript (ECO = Embedded CoffeeScript). Comments in CoffeeScript use the #
character to comment a single line (and ###
for multiline comments). See coffeescript - How to comment? "/* this */" doesn't work
So in ECO you would comment like this:
<% #This is a single line comment %>
If you examine the source code for ECO templates you can see the regex that's handling the comment situation in scanner.js.
Scanner.modePatterns = {
data: /(.*?)(<%%|<%\s*(\#)|<%(([=-])?)|\n|$)/,
code: /(.*?)((((:|(->|=>))\s*))?%>|\n|$)/,
comment: /(.*?)(%>|\n|$)/
};
Upvotes: 3