Escaped unicode characters in a tempate parameter variable

Seems go template parser is not passing on my font awesome unicode. I tried double escaping to no avail.

 [params.sections]
    font = "Acme"
    # maxFont =
    # fontRatio =
    bullet_icon = "\f069"   # the font awesome hex number  "\nnnn"

    {{ with .bullet_icon }}
    .section__content li::before {
      content: "{{ . }}";
    }
    {{ end }}

if I double escape I get \f069 on the rendered page.
if I single escape I get 060. In neither case do I get the font awesome asterisk.
If I hard code \f069 in to the content property it works fine so it’s something that the go template processor is doing.

When it sees \ in a parameter value does it process as escaped character it or just pass it through. If the former how to tell it to use it literally?

could the toml parser be the issue. I see it parses escaped characters in strings.

further it says use single quotes for literals…I tried that…doesn’t work, same issue…seems to be the go template.

bullet_icon = '\f069'

I believe the correct TOML formatting is "\uf069".

I had already tried that. Toml hates it. That line and all further toml is ignored (not parsed).

I think I need someone to try this on their own to duplicate this issue. I can’t determine it it’s toml, go templates,

safeCSS function? Assuming this templating is going between two <style> tags, yeah?

{{ with .bullet_icon }}
.section__content li::before {
    content: '{{ . | safeCSS }}';
}
{{ end }}

Or put the entire line content: XXX as a string and pass through safeCSS?

I’ll look into what the TOML spec actually requires, but you have to use uppercase hex values with the existing TOML library we’re using: \uF069.

bullet_icon = "\uF069"

seriously :0… All I needed was uppercase F, that works!..hours wasted…thx

Fix submitted upstream.

1 Like

@rdwatters I’ll try this too just for future reference, but @moorereason orereason came up with a simple correct answer.

Didn’t even know about safecss (say that fast ha ha).
I don’t see it buried in the functions page and your link takes me to https://hugodocs.info/ which I didn’t even know existed but must be the upcoming release? It has a better toc which would have made it easier to find.

Thx.

1 Like