I was feeling really happy with some shortcodes I wrote for defining terms and creating popups.
I wondered if I could automatically add the term to a taxonomy, which meant take a parameter passed to a shortcode and add it to .Page.Params.tags
. I tried:
{{ $term := .Get 0 }}<br/>
{{ $newtag := slice ( $term ) }}
{{ if isset .Page.Params "tags" }}
{{ $tags := .Page.Params.tags }}
{{ $tags = $tags | append $newtag }}
<br/>$tags: {{ $tags }}
{{ end }}
<br/>TAGS: {{ .Page.Params.tags }}
When this runs, I see the new term (parameter 0 to the shortcode) along with hardcoded front matter in the “tags” variable on the HTML page after $tags
.
If I include {{ .Page.Params.tags := $tags }}
before the TAGS:
line above, I get an error: defdef.html:7:1": parse failed unexpected “:=” in operand
If I include {{ .Page.Params.tags = $tags }}
before the TAGS:
line above, I get an error: defdef.html:7:1": parse failed unexpected “=” in operand
It seems there is no way to update the .Page.Params.tags
variable. Am I trying to attempt the impossible here?