[SOLVED] Formatting text inside a dict


#1

Can a block inside of a dict be formatted in some way. I’d like to process a carriage return and a list.


#2

@justrjlewis Can you point me to your example? My first thought is that the value in the key-value you pass into a dict could be run through the markdownify function. I tried it with \n, which doesn’t work, but <br> should work…


#3

Well, I’m testing out the Victor Hugo starter from Netlify and majority of the template files have something similar to:

{{ partial "media-block" (dict "heading" "If it aint broke, don't break it." "text" "Not every business needs a multi-million dollar marketing team, but every business should be engaging their customers in the digital space. I specialize in helping small business professionals craft digital content strategies without breaking the bank." "imageUrl" "/img/about/aint-broken.jpg") }}

I tried \n as well as plain html (screenshot). I thought it might need to be escaped, but wasn’t clear on making that work. I’ll try running it through mardownify and post my results back.

Thanks for the idea!


#4

Okay - neither \n, or \r work alone, but with markdownify applied to the block, \n\r does work. Still working on lists as inserting an actual list throws an error

95: Failed to add template about/single.html in path /Users/justrjlewis/source/0-dev/sites/rjlewisdigital-rtw2017/site/layouts/about/single.html: template: about/single.html:7: unterminated quoted string

#5

Update [SOLVED] -

Mardownify was the answer. Adding a list as below gets the job done.

{{ partial "media-block" (dict "heading" "If it aint broke, don't break it." "text" "Not every business needs a multi-million dollar marketing team, but every business should be engaging their customers in the digital space. \n\r - I specialize \n\r - in helping small \n\r - business professionals craft digital content strategies without breaking the bank." "imageUrl" "/img/about/aint-broken.jpg") | markdownify }}