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