From f6789f517cb5bf8f1642bfc5424878d5dfc775d9 Mon Sep 17 00:00:00 2001 From: harttle Date: Fri, 3 Apr 2020 23:07:52 +0800 Subject: [PATCH] docs: make it clear for extnames, see #214 --- docs/source/tutorials/options.md | 4 ++-- docs/source/tutorials/partials-and-layouts.md | 12 ++++++++---- docs/source/zh-cn/tutorials/options.md | 6 +++--- docs/source/zh-cn/tutorials/partials-and-layouts.md | 4 ++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/source/tutorials/options.md b/docs/source/tutorials/options.md index ac48b93bd..1dbe9ae5e 100644 --- a/docs/source/tutorials/options.md +++ b/docs/source/tutorials/options.md @@ -45,8 +45,8 @@ LiquidJS defaults this option to true to be compatible with shopify **extname** defines the default extname to be appended into filenames if the filename has no extname. Defaults to `''` which means it's disabled by default. By setting it to `.liquid`: ```liquid -{% render "foo" %} loads foo.liquid -{% render "foo.html" %} loads foo.html +{% render "foo" %} there's no extname, adds `.liquid` and loads foo.liquid +{% render "foo.html" %} there is an extname already, loads foo.html directly ``` {% note info Legacy Versions %} diff --git a/docs/source/tutorials/partials-and-layouts.md b/docs/source/tutorials/partials-and-layouts.md index f5f648523..eee1a285b 100644 --- a/docs/source/tutorials/partials-and-layouts.md +++ b/docs/source/tutorials/partials-and-layouts.md @@ -12,9 +12,9 @@ color: '{{ color }}' shape: '{{ shape }}' // file: theme.liquid {% assign shape = 'circle' %} -{% render 'color' %} -{% render 'color' with 'red' %} -{% render 'color', color: 'yellow', shape: 'square' %} +{% render 'color.liquid' %} +{% render 'color.liquid' with 'red' %} +{% render 'color.liquid', color: 'yellow', shape: 'square' %} ``` The output will be: @@ -27,6 +27,10 @@ color: 'yellow' shape: 'square' More details please refer to the [render](../tags/render.html) tag. +{% note tip The ".liquid" Extension %} +The ".liquid" extension in layout, render and include an be omitted if Liquid instance is created using `extname: ".liquid"` option. See the extname option for details. +{% endnote %} + ## Layout Templates (Extends) For the following template files: @@ -38,7 +42,7 @@ Header Footer // file: page.liquid -{% layout "default-layout" %} +{% layout "default-layout.liquid" %} {% block content %}My page content{% endblock %} ``` diff --git a/docs/source/zh-cn/tutorials/options.md b/docs/source/zh-cn/tutorials/options.md index 5a664bfa0..18c143913 100644 --- a/docs/source/zh-cn/tutorials/options.md +++ b/docs/source/zh-cn/tutorials/options.md @@ -43,11 +43,11 @@ LiquidJS 把这个选项默认值设为 true 以兼容于 shopify/l **extname** 定义了默认的文件后缀,当传入文件名不包含后缀时自动追加。默认值是 `''` 也就是说默认是禁用的。如果设置为 `.liquid`: ```liquid -{% render "foo" %} 会加载 foo.liquid -{% render "foo.html" %} 会加载 foo.html +{% render "foo" %} 没有后缀,添加 ".liquid" 并加载 foo.liquid +{% render "foo.html" %} 已经有后缀了,直接加载 foo.html ``` -{% note info Legacy Versions %} +{% note info 旧版行为 %} 在 2.0.1 之前,extname 默认值为 `.liquid`。要禁用它需要明确设置为 extname: ''。详情参考 #41。 {% endnote %} diff --git a/docs/source/zh-cn/tutorials/partials-and-layouts.md b/docs/source/zh-cn/tutorials/partials-and-layouts.md index f3c4b1333..531ef00cb 100644 --- a/docs/source/zh-cn/tutorials/partials-and-layouts.md +++ b/docs/source/zh-cn/tutorials/partials-and-layouts.md @@ -25,6 +25,10 @@ color: 'red' shape: 'circle' color: 'yellow' shape: 'square' ``` +{% note tip ".liquid" 文件扩展名 %} +如果设置了 `extname: ".liquid"` 选项,就可以省略 layout, renderinclude 里面文件名的 ".liquid" 后缀。详情请参考 extname 选项。 +{% endnote %} + ## 布局模板(模板继承) 对于如下两个模板文件: