From 0f824355fa9c539843a1debb6ce13a675869781a Mon Sep 17 00:00:00 2001 From: Harttle Date: Fri, 8 Jul 2022 01:59:09 +0800 Subject: [PATCH] docs: zh-cn doc for inline comment --- docs/source/tags/overview.md | 2 +- docs/source/zh-cn/tags/inline_comment.md | 50 ++++++++++++++++++++++++ docs/source/zh-cn/tags/overview.md | 2 +- docs/themes/navy/languages/zh-cn.yml | 1 + 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 docs/source/zh-cn/tags/inline_comment.md diff --git a/docs/source/tags/overview.md b/docs/source/tags/overview.md index da09baa1d..fea60f491 100644 --- a/docs/source/tags/overview.md +++ b/docs/source/tags/overview.md @@ -13,6 +13,6 @@ Iteration | iterate over a collection | for, cycle, tablerow Control Flow | control the execution branch of template rendering | if, unless, elsif, else, case, when Variable | define and alter variables | assign, increment, decrement, capture, echo File | include another template or extend a layout template | render, include, layout -Language | temporarily disable LiquidJS syntax | raw, comment, liquid +Language | temporarily disable LiquidJS syntax | # (inline comment), raw, comment, liquid [shopify/liquid]: https://github.com/Shopify/liquid diff --git a/docs/source/zh-cn/tags/inline_comment.md b/docs/source/zh-cn/tags/inline_comment.md new file mode 100644 index 000000000..5b688d51c --- /dev/null +++ b/docs/source/zh-cn/tags/inline_comment.md @@ -0,0 +1,50 @@ +--- +title: "#(单行注释)" +--- + +{% since %}v9.38.0{% endsince %} + +在 Liquid 模板中添加注释,注释标签内的文字不会被输出。 + +输入 +```liquid +注释标签内的东西都不会输出。 +{% # this is an inline comment %} +但每行都必须以 '#' 开头。 +{% + # this is a comment + # that spans multiple lines +%} +``` + +输出 +```text +注释标签内的东西都不会输出。 +但每行都必须以 '#' 开头。 +``` + +在 `liquid` 标签里也可以使用注释标签。 + +```liquid +{% liquid + # required args + assign product = collection.products.first + + # optional args + assign should_show_border = should_show_border | default: true + assign should_highlight = should_highlight | default: false +%} +``` + +但注释标签不能用于把其他标签注释掉。这时应该使用 `comment` 标签来临时禁用其他标签。 + +输入 +```liquid +{%- # {% echo 'Welcome to LiquidJS!' %} -%} +{% comment %}{% echo 'Welcome to LiquidJS!' %}{% endcomment %} +``` + +输出 +```text + -%} +``` diff --git a/docs/source/zh-cn/tags/overview.md b/docs/source/zh-cn/tags/overview.md index 4838e45ef..3ca4a5881 100644 --- a/docs/source/zh-cn/tags/overview.md +++ b/docs/source/zh-cn/tags/overview.md @@ -13,6 +13,6 @@ LiquidJS 支持十几个过滤器,可以分为如下几类: 控制流 | 控制模板渲染的执行分支 | if, unless, elif, else, case, when 变量 | 定义和修改变量 | assign, increment, decrement, capture, echo 文件 | 引入或继承其他模板 | render, include, layout -语言 | 暂时禁用 Liquid 语法 | raw, comment, liquid +语言 | 暂时禁用 Liquid 语法 | # (单行注释), raw, comment, liquid [shopify/liquid]: https://github.com/Shopify/liquid diff --git a/docs/themes/navy/languages/zh-cn.yml b/docs/themes/navy/languages/zh-cn.yml index 7b7caaa27..d42121bfe 100644 --- a/docs/themes/navy/languages/zh-cn.yml +++ b/docs/themes/navy/languages/zh-cn.yml @@ -59,6 +59,7 @@ sidebar: overview: 概述 tags: overview: 概述 + '# (inline comment)': '#(单行注释)' api: quick_entry: 快速入口 classes: 类