I created a JSON file with some objects with attributes. I am fetching this data to use in a repeat element on a page. One attribute (called “description”) is a string that I am displaying in each element like:
<p>{{_['description']}}</p>
I would like to introduce line breaks for this description, but am not sure how to do this. I have tried using \n
but this does not seem to work with fetched JSON data.
Where do you need the line breaks exactly? Can you provide an example?
Sure. Take this JSON data for example:
For the description
for Product A, how would I introduce a line break after the sentence “It does this and that.”?
Use <br>
and on the page instead of binding the data directly, use Inner HTML option which makes this code on your page:
<p dmx-html="description"></p>
instead of
<p>{{description}}</p>
1 Like
Ah fantastic - thank you
Edit: Actually had to use dmx-html="_['description']"
1 Like