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 %}
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|$)/
};