Shortcode

Get

返回给定参数的值。

签名
SHORTCODE.Get ARG
返回类型
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.