获取
Syntax
SHORTCODE.Get ARG
Returns
any
通过位置或名称指定参数。在 Markdown 中调用短代码时,可以使用位置参数或命名参数,但不能同时使用两者。
位置参数
此短代码调用使用位置参数:
content/about.md
{{< myshortcode "Hello" "world" >}}
按位置检索参数:
layouts/shortcodes/myshortcode.html
{{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world.
命名参数
此短代码调用使用命名参数:
content/about.md
{{< myshortcode greeting="Hello" firstName="world" >}}
按名称检索参数:
layouts/shortcodes/myshortcode.html
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world.