How can I pass a dictionary as argument for a custom Shortcut

I’m trying this:
In my page.md

{{<                
  my-shortcut

   $dict0 := dict
     "firstname" "John" 
     "lastname" "Lennon"
  >}}

And then accessing the $dict0 variable in my shortcut

You can only pass scalar values[1] when calling a shortcode.


  1. bool, int, float, string ↩︎

You can pass a dictionary set if you are using templates.

{{  template try (dict "key1"  "value 1" "key 2" "value 2") }}

{{ define try }}
<ul>
<li><a><h1>{{ .key1 }}</h1></a></li>
<li><a><h1>{{ .key1 }}</h1></a></li>
</ul>
{{ end }}

You can use named parameters in case of shortcodes

{{< shortcode firstname="john" lastname="lennon" >}}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.