docs: make it clear for extnames, see #214

This commit is contained in:
harttle
2020-04-03 23:08:09 +08:00
parent 5099b2a762
commit f6789f517c
4 changed files with 17 additions and 9 deletions
+2 -2
View File
@@ -45,8 +45,8 @@ LiquidJS defaults this option to <code>true</code> 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 %}
@@ -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 &quot;.liquid&quot; Extension %}
The ".liquid" extension in <code>layout</code>, <code>render</code> and <code>include</code> an be omitted if Liquid instance is created using `extname: ".liquid"` option. See <a href="./options.html#extname">the extname option</a> 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 %}
```
+3 -3
View File
@@ -43,11 +43,11 @@ LiquidJS 把这个选项默认值设为 <code>true</code> 以兼容于 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 之前,<code>extname</code> 默认值为 `.liquid`。要禁用它需要明确设置为 <code>extname: ''</code>。详情参考 <a href="https://github.com/harttle/liquidjs/issues/41" target="_blank">#41</a>。
{% endnote %}
@@ -25,6 +25,10 @@ color: 'red' shape: 'circle'
color: 'yellow' shape: 'square'
```
{% note tip &quot;.liquid&quot; 文件扩展名 %}
如果设置了 `extname: ".liquid"` 选项,就可以省略 <code>layout</code>, <code>render</code> 和 <code>include</code> 里面文件名的 ".liquid" 后缀。详情请参考 <a href="./options.html#extname">extname 选项</a>。
{% endnote %}
## 布局模板(模板继承)
对于如下两个模板文件: