HTML tags in /data/ file strings?

Hi - it’s great to be able to pull in strings from a data file, but, it appears we cannot add any formatting in the string, like we could if we were entering it directly in a page.

Specifically, since Japanese has no spaces in most text, sometimes it wraps oddly, and you have to add <wbr> tags to indicate “break here” or, put things in <nobr></nobr> tags to avoid breaking. For example, in a content file, I’m doing:

### eSoliaはどの様にマネージメント<wbr><nobr>をするのか</nobr>

This renders well enough, with the break-related tags inside the <h3>. The id is odd, but the source looks like this:

<h3 id="esoliaはどの様にマネージメント-wbr-nobr-をするのか-nobr">eSoliaはどの様にマネージメント<wbr><nobr>をするのか</nobr></h3>

I’d like to maintain my concept of using data files to supply strings to my templates, but, I wonder, is there a way I can tell Hugo to go ahead and process any embedded codes like that?

I’m pulling the strings into the template like this:

{{ ( index $.Site.Data.translations $.Site.Params.locale ).mystring }}

Is there a function I can use to make Hugo honor any tags inside these pulled strings?

Please advise.

Thanks in advance,

{{ ( index $.Site.Data.translations $.Site.Params.locale ).mystring | markdownify }}

{{ ( index $.Site.Data.translations $.Site.Params.locale ).mystring | html }}

The first is simplest I guess, as it supports Markdown.

1 Like

Much appreciate the help @bep. That will really make our lives easier. I’ll experiment tomorrow!