How Do I Create a Newline Character in a Server Action to Display Correctly in `<p dmx-text="notes">`?

I want to create a string in a server action which will create a newline character when displayed on the front end using <p dmx-text="my_action.data.notes"></p>, and will also look consistent when edited in a textarea.

In the server action I’ve done this:

sometext = 'bla bla'
newline = '\n'
notes = $_GET.notes + newline + sometext

In the paragraph on the front-end I want to see:

existing notes
bla bla

But with the code I have shown here, I see:

existing notes\nbla bla

What value do I need to give to newline?

(Note that <br> works for displaying in the <p> tag, but shows the actual text <br> when the value of notes is displayed in a textarea)

Try to use the <br> inside the dmx-html attribute…

Hi Antony,

To extend on @famousmag 's post, data from the Server Action will also need to be formatted with html compliant tags. The expression in the code editor can be built like this:

htmlStart+randomTextFirst+br+randomTextSecond+br+randomTextThird+htmlEnd

Set values for htmlStart as <html>, htmlEnd as </html>, br as <br>

Result on the client-side

Screenshot 2024-03-08 at 3.18.08 pm

1 Like