Semicolon in shortcode parameter

Hello,
I hope this isn’t too simple a question. When trying to make a shortcode in hugo, I’ve discovered a strange behaviour with a semicolon in parameter values.

Specifically, I’m trying to allow some custom css styling for a shortcode element.

Here is an example of what such a shortcode might look like:
{{ .Get “cell-style” }}
<div style="{{ .Get “cell-style” }}">
test
</div>

And how it would be used:
{{< test cell-style="border:1px solid black" >}}

This would render predictably, a div with a border.
But if I add a semicolon like this:
{{< test cell-style="border:1px solid black;" >}}

The first line would show as expected: border:1px solid black;
But the style in the div turns to gibberish: style=“ZgotmplZ”

What am I doing wrong here, and is this the entirely wrong thing to do?

(The semicolon would be needed for multiple styles)

Ah, found it :neutral_face:

Piping to safeCSS allows the semicolon
<div style="{{ .Get "cell-style" | safeCSS}}">

4 Likes

:slight_smile: next time google the gibberish - that could help more often than you think. That’s a default (but weird) error code that exactly predicted your solution :slight_smile:

There are many useful safeSOMETHING functions in Hugo.