How do comments work in Craft? I mean inline and multiline comments, like:
HTML: <!--xxx--> m
JS: /*xxx*/ m //xxx i
PHP: /*xxx*/ m //xxx i #xxx i
There's only one comment syntax for Craft / Twig:
{# ... #}
Anything in between won't be parsed by Twig, so you can comment out multiple lines of Twig and HTML like so:
{#
{% set var = value %}
{% for item in seq %}
<p>{{ item }}</p>
{% endfor %}
#}
As with many other languages you can't nest comments! So if you want to comment out some lines of code that already have comments, you can't do that like so:
{#
{#
# Lots of comments going on here
#}
{% set var = value %}
{# I warned you #}
{% for item in seq %}
<p>{{ item }}</p>
{% endfor %}
#}
The best workaround I found is to use HTML comments in combination with Twigs verbatim
tags (disables Twig parsing).
I added a snippet to my editor for this and use it regularly since:
{% verbatim %}
<!--
{#
# Lots of comments going on here
#}
{% set var = value %}
{# I warned you #}
{% for item in seq %}
{% endfor %}
-->
{% endverbatim %}