0
Under review

Textfield line breaks in HTML

doug 6 years ago updated by icahill (Administrator) 6 years ago 5
How would I go about mimicking/converting line breaks in a multi-line textfield to HTML. I have a large textfield where a user can type an email message, but I cant translate those line breaks to HTML to send to Mandrill.
Under review
So you are simply trying to send a multiline textfield's content and send it to Mandrill with breaks intact?
That is correct.
Have you tried pulling the encodedtext rather than regular text?

[object:TEXT.encodedtext]
As far as I can tell, this isn't working for me. I to be able to get the value of the textfield with the line breaks intact, show a preview of it in a web view so the user can review what the email will look like, then send it with mandrill. So with that said, the line breaks need to be <br />
Doug,

The solution to this actually was to correct a small bug in how textfields returned breaks. 

What you would need to do is pull in the textfield content to a texttemplate and run a replace eval to turn \n into </br> like this:

<assign property="var:final" value='[eval: "[template:url.content]".replace(/[template:newline.content]/g,"[template:break.content]") ]'/>

<texttemplate name="url"><![CDATA[[var:textfieldcontent]]]></texttemplate>
<texttemplate name="break"><![CDATA[<br/>]]></texttemplate>
<texttemplate name="newline"><![CDATA[\n]]></texttemplate>

The fix that will enable this is on 1.5 Development branch. Hit me up through email and I can move your project to that build if you want to test on it. 

Thanks