From 8e5911d3ee0a500c9e4cfe3748b18dd8bff8228c Mon Sep 17 00:00:00 2001 From: Shaina Raskas Date: Wed, 19 Oct 2022 10:43:53 -0400 Subject: [PATCH] document inline comments --- _tags/template.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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/).