docs: add versions to tags/filters, see #305

This commit is contained in:
harttle
2021-03-21 22:17:17 +08:00
parent 2133ed20d7
commit 695e3c18bc
129 changed files with 262 additions and 2 deletions
+6 -2
View File
@@ -2,7 +2,7 @@
'use strict'
hexo.extend.tag.register('note', (args, content) => {
hexo.extend.tag.register('note', (args, text) => {
const className = args.shift()
let header = ''
let result = ''
@@ -12,8 +12,12 @@ hexo.extend.tag.register('note', (args, content) => {
}
result += `<blockquote class="note ${className}">${header}`
result += hexo.render.renderSync({ text: content, engine: 'markdown' })
result += hexo.render.renderSync({ text, engine: 'markdown' })
result += '</blockquote>'
return result
}, true)
hexo.extend.tag.register('since', (args, text) => {
return `<p class="since">Added in: ${text.trim()}</p>`
}, true)
+2
View File
@@ -2,6 +2,8 @@
title: abs
---
{% since %}v1.9.1{% endsince %}
Liquid filter that returns the absolute value of a number.
Input
+2
View File
@@ -2,6 +2,8 @@
title: append
---
{% since %}v1.9.1{% endsince %}
Concatenates two strings and returns the concatenated value.
Input
+2
View File
@@ -2,6 +2,8 @@
title: at_least
---
{% since %}v8.4.0{% endsince %}
Limits a number to a minimum value.
Input
+2
View File
@@ -2,6 +2,8 @@
title: at_most
---
{% since %}v8.4.0{% endsince %}
Limits a number to a maximum value.
Input
+2
View File
@@ -2,6 +2,8 @@
title: capitalize
---
{% since %}v1.9.1{% endsince %}
Makes the first character of a string capitalized.
Input
+2
View File
@@ -2,6 +2,8 @@
title: ceil
---
{% since %}v1.9.1{% endsince %}
Rounds the input up to the nearest whole number. LiquidJS tries to convert the input to a number before the filter is applied.
Input
+2
View File
@@ -2,6 +2,8 @@
title: compact
---
{% since %}v9.22.0{% endsince %}
Removes any `nil` values from an array.
For this example, assume `site.pages` is an array of content pages for a website, and some of these pages have an attribute called `category` that specifies their content category. If we `map` those categories to an array, some of the array items might be `nil` if any pages do not have a `category` attribute.
+2
View File
@@ -2,6 +2,8 @@
title: date
---
{% since %}v1.9.1{% endsince %}
Converts a timestamp into another date format. LiquidJS tries to be conformant with Shopify/Liquid which is using Ruby's core [Time#strftime(string)](http://www.ruby-doc.org/core/Time.html#method-i-strftime). The input is firstly converted to `Date` object via [new Date()][newDate].
Input
+2
View File
@@ -2,6 +2,8 @@
title: default
---
{% since %}v1.9.1{% endsince %}
Allows you to specify a fallback in case a value doesn't exist. `default` will show its value if the left side is [falsy][falsy] or empty (`string` or `Array`).
In this example, `product_price` is not defined, so the default value is used.
+2
View File
@@ -2,6 +2,8 @@
title: divided_by
---
{% since %}v1.9.1{% endsince %}
Divides a number by another number. The result is the string obtained by JavaScript `.toString()` of the result number.
Input
+2
View File
@@ -2,6 +2,8 @@
title: downcase
---
{% since %}v1.9.1{% endsince %}
Makes each character in a string lowercase. It has no effect on strings which are already all lowercase.
Input
+2
View File
@@ -2,6 +2,8 @@
title: escape
---
{% since %}v1.9.1{% endsince %}
Escapes a string by replacing HTML special characters with escape sequences. It doesn't change strings that don't have anything to escape.
Input
+2
View File
@@ -2,6 +2,8 @@
title: escape_once
---
{% since %}v1.9.1{% endsince %}
Escapes a string without changing existing escaped entities. It doesn't change strings that don't have anything to escape.
Input
+2
View File
@@ -2,6 +2,8 @@
title: first
---
{% since %}v1.9.1{% endsince %}
Returns the first item of an array.
Input
+2
View File
@@ -2,6 +2,8 @@
title: floor
---
{% since %}v1.9.1{% endsince %}
Rounds the input down to the nearest whole number. LiquidJS tries to convert the input to a number before the filter is applied.
Input
+2
View File
@@ -2,6 +2,8 @@
title: join
---
{% since %}v1.9.1{% endsince %}
Combines the items in an array into a single string using the argument as a separator.
Input
+2
View File
@@ -2,6 +2,8 @@
title: json
---
{% since %}v9.10.0{% endsince %}
Convert values to string via `JSON.stringify()`, for debug purpose.
Input
+2
View File
@@ -2,6 +2,8 @@
title: last
---
{% since %}v1.9.1{% endsince %}
Returns the last item of an array.
Input
+2
View File
@@ -2,6 +2,8 @@
title: lstrip
---
{% since %}v1.9.1{% endsince %}
Removes all whitespace (tabs, spaces, and newlines) from the left side of a string. It does not affect spaces between words.
Input
+2
View File
@@ -2,6 +2,8 @@
title: map
---
{% since %}v1.9.1{% endsince %}
Creates an array of values by extracting the values of a named property from another object.
In this example, assume the object `site.pages` contains all the metadata for a website. Using `assign` with the `map` filter creates a variable that contains only the values of the `category` properties of everything in the `site.pages` object.
+2
View File
@@ -2,6 +2,8 @@
title: minus
---
{% since %}v1.9.1{% endsince %}
Subtracts a number from another number.
Input
+2
View File
@@ -2,6 +2,8 @@
title: modulo
---
{% since %}v1.9.1{% endsince %}
Returns the remainder of a division operation.
Input
+2
View File
@@ -2,6 +2,8 @@
title: newline_to_br
---
{% since %}v1.9.1{% endsince %}
Replaces every newline (`\n`) in a string with an HTML line break (`<br />`).
Input
+2
View File
@@ -2,6 +2,8 @@
title: plus
---
{% since %}v1.9.1{% endsince %}
Adds a number to another number.
Input
+2
View File
@@ -2,6 +2,8 @@
title: prepend
---
{% since %}v1.9.1{% endsince %}
Adds the specified string to the beginning of another string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: remove
---
{% since %}v1.9.1{% endsince %}
Removes every occurrence of the specified substring from a string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: remove_first
---
{% since %}v1.9.1{% endsince %}
Removes only the first occurrence of the specified substring from a string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: replace
---
{% since %}v1.9.1{% endsince %}
Replaces every occurrence of the first argument in a string with the second argument.
Input
+2
View File
@@ -2,6 +2,8 @@
title: replace_first
---
{% since %}v1.9.1{% endsince %}
Replaces only the first occurrence of the first argument in a string with the second argument.
Input
+2
View File
@@ -2,6 +2,8 @@
title: reverse
---
{% since %}v1.9.1{% endsince %}
Reverses the order of the items in an array. `reverse` cannot reverse a string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: round
---
{% since %}v1.9.1{% endsince %}
Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.
Input
+2
View File
@@ -2,6 +2,8 @@
title: rstrip
---
{% since %}v1.9.1{% endsince %}
Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between words.
Input
+2
View File
@@ -2,6 +2,8 @@
title: size
---
{% since %}v1.9.1{% endsince %}
Returns the number of characters in a string or the number of items in an array.
Input
+2
View File
@@ -2,6 +2,8 @@
title: slice
---
{% since %}v1.9.1{% endsince %}
Returns a substring of 1 character beginning at the index specified by the first argument. An optional second argument specifies the length of the substring to be returned.
String indices are numbered starting from 0.
+2
View File
@@ -2,6 +2,8 @@
title: sort
---
{% since %}v1.9.1{% endsince %}
Sorts items in an array in case-sensitive order.
Input
+2
View File
@@ -2,6 +2,8 @@
title: sort_natural
---
{% since %}v8.4.0{% endsince %}
Sorts items in an array in case-insensitive order.
Input
+2
View File
@@ -2,6 +2,8 @@
title: split
---
{% since %}v1.9.1{% endsince %}
Divides a string into an array using the argument as a separator. `split` is commonly used to convert comma-separated items from a string to an array.
Input
+2
View File
@@ -2,6 +2,8 @@
title: strip
---
{% since %}v1.9.1{% endsince %}
Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between words.
Input
+2
View File
@@ -2,6 +2,8 @@
title: strip_html
---
{% since %}v1.9.1{% endsince %}
Removes any HTML tags from a string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: strip_newlines
---
{% since %}v1.9.1{% endsince %}
Removes any newline characters (line breaks) from a string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: times
---
{% since %}v1.9.1{% endsince %}
Multiplies a number by another number.
Input
+2
View File
@@ -2,6 +2,8 @@
title: truncate
---
{% since %}v1.9.1{% endsince %}
Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (...) is appended to the string and is included in the character count.
## Basic Usage
+2
View File
@@ -2,6 +2,8 @@
title: truncatewords
---
{% since %}v1.9.1{% endsince %}
Shortens a string down to the number of words passed as an argument. If the specified number of words is less than the number of words in the string, an ellipsis (...) is appended to the string.
Input
+2
View File
@@ -2,6 +2,8 @@
title: uniq
---
{% since %}v1.9.1{% endsince %}
Removes any duplicate elements in an array.
Input
+2
View File
@@ -2,6 +2,8 @@
title: upcase
---
{% since %}v1.9.1{% endsince %}
Makes each character in a string uppercase. It has no effect on strings which are already all uppercase.
Input
+2
View File
@@ -2,6 +2,8 @@
title: url_decode
---
{% since %}v6.1.0{% endsince %}
Decodes a string that has been encoded as a URL.
Input
+2
View File
@@ -2,6 +2,8 @@
title: url_encode
---
{% since %}v1.9.1{% endsince %}
Converts any URL-unsafe characters in a string into percent-encoded characters.
Input
+2
View File
@@ -2,6 +2,8 @@
title: where
---
{% since %}v8.1.0{% endsince %}
Creates an array including only the objects with a given property value, or any [truthy][truthy] value by default.
In this example, assume you have a list of products and you want to show your kitchen products separately. Using `where`, you can create an array containing only the products that have a `"type"` of `"kitchen"`.
+2
View File
@@ -2,6 +2,8 @@
title: Assign
---
{% since %}v1.9.1{% endsince %}
Creates a new variable.
Input
+2
View File
@@ -2,6 +2,8 @@
title: capture
---
{% since %}v1.9.1{% endsince %}
Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created through `capture` are strings.
Input
+2
View File
@@ -2,6 +2,8 @@
title: case
---
{% since %}v1.9.1{% endsince %}
Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` compares its values.
Input
+2
View File
@@ -2,6 +2,8 @@
title: Comment
---
{% since %}v1.9.1{% endsince %}
Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing `comment` blocks will not be printed, and any Liquid code within will not be executed.
Input
+2
View File
@@ -2,6 +2,8 @@
title: cycle
---
{% since %}v1.9.1{% endsince %}
Loops through a group of strings and prints them in the order that they were passed as arguments. Each time `cycle` is called, the next string argument is printed.
## Basic Usage
+2
View File
@@ -2,6 +2,8 @@
title: Decrement
---
{% since %}v1.9.1{% endsince %}
Creates a new number variable, and decreases its value by one every time it is called. The first value is `-1`.
Input
+2
View File
@@ -2,6 +2,8 @@
title: For
---
{% since %}v1.9.1{% endsince %}
Iteration tags run blocks of code repeatedly.
## Basic Usage
+2
View File
@@ -2,6 +2,8 @@
title: If
---
{% since %}v1.9.1{% endsince %}
Executes a block of code only if a certain condition is `true`.
## if
+2
View File
@@ -2,6 +2,8 @@
title: Include
---
{% since %}v1.9.1{% endsince %}
{% note warn Deprecated %}
This tag is deprecated, use <a href="./render.html">render</a> tag instead for better encapsulation.
{% endnote %}
+2
View File
@@ -2,6 +2,8 @@
title: Increment
---
{% since %}v1.9.1{% endsince %}
Creates a new number variable, and increases its value by one every time it is called. The first value is `0`.
Input
+2
View File
@@ -2,6 +2,8 @@
title: Layout
---
{% since %}v1.9.1{% endsince %}
## Using a Layout Template
Renders current template inside a layout template from the template [roots][root].
+2
View File
@@ -2,6 +2,8 @@
title: Raw
---
{% since %}v1.9.1{% endsince %}
Raw temporarily disables tag processing. This is useful for generating content
(eg, Mustache, Handlebars) which uses conflicting syntax.
+2
View File
@@ -2,6 +2,8 @@
title: Render
---
{% since %}v9.2.0{% endsince %}
## Basic Usage
### Render a Template
+2
View File
@@ -2,6 +2,8 @@
title: Table Row
---
{% since %}v1.9.1{% endsince %}
Generates an HTML table. Must be wrapped in opening `<table>` and closing `</table>` HTML tags.
## Basic Usage
+2
View File
@@ -2,6 +2,8 @@
title: Unless
---
{% since %}v1.9.1{% endsince %}
The opposite of `if` executes a block of code only if a certain condition is **not** met.
Input
+2
View File
@@ -2,6 +2,8 @@
title: abs
---
{% since %}v1.9.1{% endsince %}
返回数字的绝对值。
输入
+2
View File
@@ -2,6 +2,8 @@
title: append
---
{% since %}v1.9.1{% endsince %}
连接两个字符串并返回结果。
输入
+2
View File
@@ -2,6 +2,8 @@
title: at_least
---
{% since %}v8.4.0{% endsince %}
限制数字到某个最小值。
输入
+2
View File
@@ -2,6 +2,8 @@
title: at_most
---
{% since %}v8.4.0{% endsince %}
限制数字到某个最大值。
输入
+2
View File
@@ -2,6 +2,8 @@
title: capitalize
---
{% since %}v1.9.1{% endsince %}
把字符串首字母改为大写。
输入
+2
View File
@@ -2,6 +2,8 @@
title: ceil
---
{% since %}v1.9.1{% endsince %}
向上取整,取整前 LiquidJS 会首先把输入转换为数字。
输入
+2
View File
@@ -2,6 +2,8 @@
title: compact
---
{% since %}v9.22.0{% endsince %}
从数组里移除任何 `null``undefined` 值。
假设 `site.pages` 是网页列表,有些网页包含 `category` 属性用来标明类别。如果把它们 `map` 到数组里,那么对于没有 `category` 属性的元素就会是 `undefined`
+2
View File
@@ -2,6 +2,8 @@
title: date
---
{% since %}v1.9.1{% endsince %}
把时间戳转换为字符串。LiquidJS 尝试跟 Shopify/Liquid 保持一致,它用的是 Ruby 核心的 [Time#strftime(string)](http://www.ruby-doc.org/core/Time.html#method-i-strftime)。此外 LiquidJS 会先通过 [new Date()][newDate] 尝试把输入转换为 Date 对象。
输入
+2
View File
@@ -2,6 +2,8 @@
title: default
---
{% since %}v1.9.1{% endsince %}
在值不存在时给一个默认值,如果左侧是 [falsy][falsy] 或空(`string``Array`)就会使用这个默认值。下面的例子中 `product_price` 没有定义,因此使用了默认值。
输入
+2
View File
@@ -2,6 +2,8 @@
title: divided_by
---
{% since %}v1.9.1{% endsince %}
两数相除返回商,返回结果数字在 JavaScript 中 `.toString()` 得到的字符串。
输入
+2
View File
@@ -2,6 +2,8 @@
title: downcase
---
{% since %}v1.9.1{% endsince %}
字符串中每个字符都转为小写,对已经是小写的字符没有影响。
输入
+2
View File
@@ -2,6 +2,8 @@
title: escape
---
{% since %}v1.9.1{% endsince %}
把字符串中的 HTML 特殊字符转义,对不需要转义的字符串不会产生影响。
输入
+2
View File
@@ -2,6 +2,8 @@
title: escape_once
---
{% since %}v1.9.1{% endsince %}
把字符串中的特殊字符转义得到可用在 URL 里的字符串,对已经转义过的字符串和不需要转义的字符串不会产生影响。
输入
+2
View File
@@ -2,6 +2,8 @@
title: first
---
{% since %}v1.9.1{% endsince %}
返回数组的第一个元素。
输入
+2
View File
@@ -2,6 +2,8 @@
title: floor
---
{% since %}v1.9.1{% endsince %}
数字下取整,LiquidJS 会尝试把输入转换为数字再做下取整操作。
输入
+2
View File
@@ -2,6 +2,8 @@
title: join
---
{% since %}v1.9.1{% endsince %}
把数组中的元素连接成为一个字符串,以传入的参数作为分隔符。
输入
+2
View File
@@ -2,6 +2,8 @@
title: json
---
{% since %}v9.10.0{% endsince %}
通过 `JSON.stringify()` 把值转换为字符串,多用于调试用途。
输入
+2
View File
@@ -2,6 +2,8 @@
title: last
---
{% since %}v1.9.1{% endsince %}
返回数组的最后一个元素。
输入
+2
View File
@@ -2,6 +2,8 @@
title: lstrip
---
{% since %}v1.9.1{% endsince %}
移除字符串左侧的空白字符(制表符、空格、换行),不影响词之间的空格。
输入
+2
View File
@@ -2,6 +2,8 @@
title: map
---
{% since %}v1.9.1{% endsince %}
按照属性名提取对象的属性形成另一个数组并返回。
下面的例子中假设 `site.pages` 包含了站点的所有网页元信息。使用 `assign``map` 过滤器创建了一个 `site.pages` 中所有对象的 `category` 属性的值构成的数组。
+2
View File
@@ -2,6 +2,8 @@
title: minus
---
{% since %}v1.9.1{% endsince %}
两数相减。
输入
+2
View File
@@ -2,6 +2,8 @@
title: modulo
---
{% since %}v1.9.1{% endsince %}
返回两数相除的余数。
输入
@@ -2,6 +2,8 @@
title: newline_to_br
---
{% since %}v1.9.1{% endsince %}
把字符串里的所有换行符(`\n`)替换为 HTML 换行(`<br />`)。
输入
+2
View File
@@ -2,6 +2,8 @@
title: plus
---
{% since %}v1.9.1{% endsince %}
两数相加。
输入
+2
View File
@@ -2,6 +2,8 @@
title: prepend
---
{% since %}v1.9.1{% endsince %}
在字符串开头添加另一个字符串。
输入
+2
View File
@@ -2,6 +2,8 @@
title: remove
---
{% since %}v1.9.1{% endsince %}
移除字符串中出现的所有指定子字符串。
输入
@@ -2,6 +2,8 @@
title: remove_first
---
{% since %}v1.9.1{% endsince %}
移除字符串中出现的第一个指定子字符串。
输入
+2
View File
@@ -2,6 +2,8 @@
title: replace
---
{% since %}v1.9.1{% endsince %}
把字符串中出现的每一个指定子字符串替换为另一个字符串。
输入
@@ -2,6 +2,8 @@
title: replace_first
---
{% since %}v1.9.1{% endsince %}
把字符串中出现的第一个指定子字符串替换为另一个字符串。
输入
+2
View File
@@ -2,6 +2,8 @@
title: reverse
---
{% since %}v1.9.1{% endsince %}
反转数组的所有元素,不可用于字符串。
输入
+2
View File
@@ -2,6 +2,8 @@
title: round
---
{% since %}v1.9.1{% endsince %}
数字四舍五入取整,如果传入小数位数作为参数。
输入
+2
View File
@@ -2,6 +2,8 @@
title: rstrip
---
{% since %}v1.9.1{% endsince %}
移除字符串右侧的空白字符(制表符、空格、换行),不影响词之间的空格。
输入
+2
View File
@@ -2,6 +2,8 @@
title: size
---
{% since %}v1.9.1{% endsince %}
返回字符串的字符个数或者数组的元素个数。
输入
+2
View File
@@ -2,6 +2,8 @@
title: slice
---
{% since %}v1.9.1{% endsince %}
返回第一个参数为下标位置的一个字符,如果指定了第二个参数会被解释为子字符串的长度。字符串下标从零开始。
输入
+2
View File
@@ -2,6 +2,8 @@
title: sort
---
{% since %}v1.9.1{% endsince %}
对数组中的元素排序,排序方式为 JavaScript `Array.prototype.sort()`
输入
@@ -2,6 +2,8 @@
title: sort_natural
---
{% since %}v8.4.0{% endsince %}
大小写不敏感地对数组元素排序。
输入

Some files were not shown because too many files have changed in this diff Show More