mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
docs: fix styles and escape
This commit is contained in:
@@ -92,7 +92,7 @@ engine.registerTag('random', {
|
||||
})
|
||||
```
|
||||
|
||||
Rendering `{% random from:2, to:max %}` in scope `{ max: 10 }` will generate a random number in the range [2, 10]. See this JSFiddle: <https://jsfiddle.net/ctj364up/4/>
|
||||
Rendering `{% raw %}{% random from:2, to:max %}{% endraw %}` in scope `{ max: 10 }` will generate a random number in the range [2, 10]. See this JSFiddle: <https://jsfiddle.net/ctj364up/4/>
|
||||
|
||||
|
||||
[register-tags]: /tutorials/register-filters-tags.html
|
||||
|
||||
@@ -24,8 +24,8 @@ Expected output:
|
||||
|
||||
Firstly, [register][register-tags] a tag with name `wrap` and parse the content into `this.tpls`. Here in `parse(tagToken, remainTokens)`,
|
||||
|
||||
- `tagToken` is current token `{% wrap %}`, and
|
||||
- `remainTokens` is an array of all tokens following `{% wrap %}` until the end of this template file.
|
||||
- `tagToken` is current token `{%raw%}{% wrap %}{%endraw%}`, and
|
||||
- `remainTokens` is an array of all tokens following `{%raw%}{% wrap %}{%endraw%}` until the end of this template file.
|
||||
|
||||
Basically, what we need to do is take/`.shift()` enough tags from `remainTokens` until we got a `endwrap` token (the name can be arbitrary, but in convention, we need it to be `endwrap`). And if there's no `endwrap` until the end of template file, we need to throw an tag-not-closed `Error`.
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ engine.registerTag('random', {
|
||||
})
|
||||
```
|
||||
|
||||
在 `{ max: 10 }` 上下文上渲染 `{% random from:2, to:max %}` 将会得到 [2, 10] 范围内的随机数。见这个 JSFiddle:<http://jsfiddle.net/ctj364up/4/>。
|
||||
在 `{ max: 10 }` 上下文上渲染 `{% raw %}{% random from:2, to:max %}{% endraw %}` 将会得到 [2, 10] 范围内的随机数。见这个 JSFiddle:<http://jsfiddle.net/ctj364up/4/>。
|
||||
|
||||
[register-tags]: /tutorials/register-filters-tags.html
|
||||
[Tokenizer]: /api/classes/Tokenizer.html
|
||||
|
||||
@@ -24,7 +24,7 @@ title: 渲染标签内容
|
||||
|
||||
首先 [注册][register-tags] 一个名为 `wrap` 的标签,把内容解析到 `this.tpls` 数组里。`parse(tagToken, remainTokens)` 中,
|
||||
|
||||
- `tagToken` 是当前 *Token* `{% wrap %}`,
|
||||
- `tagToken` 是当前 *Token* `{%raw%}{% wrap %}{%endraw%}`,
|
||||
- `remainTokens` 是当前模板中后续所有 *Token* 的数组。
|
||||
|
||||
我们要做的是从 `remainTokens` 里拿出来/`.shift()` 足够的标签直到遇到 `endwrap`(其实可以是任意名字,但按照惯例应该叫 `endwrap`)。如果到模板结尾都没遇到 `endwrap`,需要抛出一个标签未关闭的 `Error`。
|
||||
|
||||
+4
-1
@@ -41,8 +41,10 @@ pre
|
||||
table
|
||||
margin: 0 !important
|
||||
border: 0
|
||||
th, td
|
||||
.gutter, .code
|
||||
padding: 0
|
||||
.gutter
|
||||
padding-right: 12px
|
||||
figcaption
|
||||
clearfix()
|
||||
margin: -5px 0 5px
|
||||
@@ -53,6 +55,7 @@ pre
|
||||
margin: 0
|
||||
padding: 0
|
||||
background: none
|
||||
white-space: pre
|
||||
.line
|
||||
height: 22px
|
||||
|
||||
|
||||
+2
-1
@@ -38,7 +38,8 @@ note-warn = hsl(0, 100%, 50%)
|
||||
margin: 40px auto
|
||||
.sidebar-title
|
||||
border-top: none
|
||||
|
||||
.toc-item
|
||||
list-style: none
|
||||
.toc-link
|
||||
@extend .sidebar-link
|
||||
|
||||
|
||||
Reference in New Issue
Block a user