获取
语法
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.