I have a snippet params in some of my blog pages, with new lines like so
snippet: |
What’s happening in China is really interesting. If we trust their official figures and estimates, the economy was driven by 3 things
1. Real estate (who’s crashing hard)
2. Consumer spending (who’s in decline, as their population is not growing and aging)
3. Exports (who are threatened by India and South East Asia)
Then in a partial I have the following to render the text on top of an image
{{ if .Page.Params.Snippet }}
{{ $img = $img.Filter (images.Text .Page.Params.Snippet (dict
"color" "#ffffff"
"size" 32
"linespacing" 2
"x" 40
"y" 150
"font" $mediumFont
))}}
{{ end }}
However, the new lines are not rendered. I’ve tried a couple of things but end up either having raw html or having an HTML object instead of a string passed to images.Text.
Does someone have any idea on how to approach this?
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space.
The unicode.IsSpace function treats a newline as whitespace, so this simple approach to word wrapping eats the line breaks.