Shortcode

Params

返回短代码参数的集合。

签名
SHORTCODE.Params
返回类型
any

用位置参数调用短代码时,Params 方法返回一个切片。

content/about.md
{{< myshortcode "Hello" "world" >}}
layouts/_shortcodes/myshortcode.html
{{ index .Params 0 }} → Hello
{{ index .Params 1 }} → world

用命名参数调用短代码时,Params 方法返回一个映射。

content/about.md
{{< myshortcode greeting="Hello" name="world" >}}
layouts/_shortcodes/myshortcode.html
{{ .Params.greeting }} → Hello
{{ .Params.name }} → world