Craft CMS Asked by Jake Dohm on September 4, 2021
I need to convert a new line in a plain multiline text field in Craft into a comma.
My text looks like:
1 Infinite Loop
Cupertino, CA
and I want to convert it to: 1 Infinite Loop, Cupertino, CA
I tried doing {{ text|nl2br|replace({ '<br>', ', ' })|raw }}
but that didn’t work.
I figured out that the best way to do this was to replace the newline character n
.
Final code:
{{ plainText|replace({ "n" : ", "}) }}
Answered by Jake Dohm on September 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP