diff --git a/_tags/template.md b/_tags/template.md index 0db116cd..b0b542e6 100644 --- a/_tags/template.md +++ b/_tags/template.md @@ -34,6 +34,54 @@ Anything you put between {% comment %} and {% endcomment %} tags is {{ verb }} into a comment. ``` +## Inline comments {%- include version-badge.html version="5.4.0" %} + +You can use inline comments to prevent an expression from being rendered or output. Any text inside of the tag also won't be rendered or output. + +You can create multi-line inline comments. However, each line must begin with a `#`. + +

Input

+```liquid +{%- raw -%} +{% # for i in (1..3) -%} + {{ i }} +{% # endfor %} + +{% + ############################### + # This is a comment + # across multiple lines + ############################### +%} +{% endraw %} +``` + +

Output

+```text + + +``` + +### Inline comments inside `liquid` tags + +You can use the inline comment tag inside [`liquid` tags](#liquid). The tag must be used for each line that you want to comment. + +

Input

+```liquid +{%- raw -%} +{% liquid + # this is a comment + assign topic = 'Learning about comments!' + echo topic +%} +{% endraw %} +``` + +

Output

+```text +Learning about comments! +``` + ## raw Temporarily disables tag processing. This is useful for generating certain content that uses conflicting syntax, such as [Mustache](https://mustache.github.io/) or [Handlebars](https://handlebarsjs.com/).