HUGO
Menu
GitHub 87548 stars Mastodon

Params

返回 shortcode 参数的集合。

Syntax

SHORTCODE.Params

Returns

any

当您使用位置参数调用 shortcode 时,Params 方法返回一个切片。

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

当您使用命名参数调用 shortcode 时,Params 方法返回一个映射。

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

Last updated: January 1, 0001
Improve this page