tag: layout, block

This commit is contained in:
harttle
2016-06-24 10:44:57 +08:00
parent 8fbbec089f
commit 3695eb2d6e
8 changed files with 111 additions and 7 deletions
+28 -1
View File
@@ -49,7 +49,9 @@ var html = engine.renderFile("hello.html", {name: 'alice'});
`cache` default to `false`, `extname` default to `.liquid`, `root` default to `""`.
## Include
## Includes and Layouts
### Includes
```
// file: color.liquid
@@ -70,6 +72,30 @@ color: 'red' shape: 'circle'
color: 'yellow' shape: 'square'
```
### Layouts
```
// file: default-layout.html
Header
{% block content %}My default content{% endblock %}
Footer
// file: page.html
{% layout "default-layout" %}
{% block content %}My page content{% endblock %}
```
The output of `page.html`:
```
Header
My page content
Footer
```
* It's possible to define multiple blocks.
* block name is optional when there's only one block.
## Extension
Register Filters:
@@ -131,6 +157,7 @@ Tag | Document | Source | Test
`raw` | [Document](https://help.shopify.com/themes/liquid/tags/theme-tags#raw) | [Source](https://github.com/harttle/shopify-liquid/blob/master/tags/raw.js) | [Test][tt]
`comment` | [Document](https://help.shopify.com/themes/liquid/tags/theme-tags#comment) | [Source](https://github.com/harttle/shopify-liquid/blob/master/tags/comment.js) | [Test][tt]
`include` | [Document](https://help.shopify.com/themes/liquid/tags/theme-tags#include) | [Source](https://github.com/harttle/shopify-liquid/blob/master/tags/include.js) | [Test][tt]
`layout, block` | [Document](http://docs.mixture.io/templates/) | [Source](https://github.com/harttle/shopify-liquid/blob/master/tags/layout.js) | [Test][tt]
## Filters