I’m trying to get a list from within a shortcode.
{{< shortcode
name="Peter Parker"
aliases="* Spiderman * Petey">}}
And the shortcode
{{ .Get "Name" | markdownify }}
{{ .Get "Aliases" | markdownify }}
It displays well the first LI, but the second one comes raw (as an asterisk) and it doesn’t add any new line markup.
Aliases:
• Spiderman * Something
If within the shortcode I try to leave the new line, this way
{{< shortcode
name="Peter Parker"
aliases=" * Spiderman
* Petey">}}
It ends up by giving me an error
unterminated quoted string in shortcode parameter-argument: '* Alias * Something
sephore
September 12, 2020, 1:08am
2
I have a suggestion. What about using split ?
So your shortcode could be something like:
{{ .Get "name" | markdownify }}
{{ $aliases := split (.Get "aliases") "," }}
<ul>
{{ range $aliases }}
<li>{{ . }}</li>
{{ end }}
</ul>
And be used like:
{{< shortcode
name="Peter Parker"
aliases="Spiderman,Petey">}}
1 Like
Great suggestion from @sephore . Do remember that white-space at the end of an </li>
is significant, so if you’re getting mystery white-space in between items that you don’t want. . .
<ul>
{{ range $aliases }}<li>{{ . }}</li>{{ end }}
</ul>
1 Like
Suggestion accepted! Lovely, thanks!
system
Closed
September 14, 2020, 10:35pm
6
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.