transform.Unmarshal throwing error with frontmatter value

I have some frontmatter that looks something like this:

---
text:
    - a,b,c
---

I’m attempting to unmarshal it in my template like so:

{{- $listItems := (index .Params.text 0) | transform.Unmarshal (dict "delimiter" ",") -}}

…but I get the following error:

execute of template failed: template: index.html:38:69: executing "main" at <transform.Unmarshal>: error calling Unmarshal: unknown format

If I use the value directly, it works:

{{- $listItems := "a,b,c" | transform.Unmarshal (dict "delimiter" ",") -}}

Strangely, though, the following returns true:

{{ eq "a,b,c" (index .Params.text 0) }} → true

Is this a bug, or am I doing something wrong?

Thank you!

I suspect that you have some pages without a text value.

That was exactly it. I had other translations were missing values there.

Thank you so much, @bep!

1 Like

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