2

**

After continuing to play around with this I realized that I did not need to add nl2br, adding hacksaw was actually removing the formatting from the rich text field. I opened a new question here if anyone can help or has encountered this issue any help would be appreciated.

**

I have a line

 <p>{{ workItem.summary | hacksaw(words='75', append='...') }}</p>

I need to add

 nl2br

to it. I have tried

 <p>{{ workItem.summary | nl2br | hacksaw(words='75', append='...') }}</p>

and

 <p>{{ nl2br (workItem.summary hacksaw(words='75', append='...')) }}</p>

Neither worked.

Can anyone shed some light on the syntax I need to get this to work correctly?

2
  • 1
    Do you mean nl2br (new line to line break?) You have nb2lr. Feb 14 '16 at 23:47
  • Ya that is what I meant Feb 15 '16 at 0:48
5

I believe filters are applied in the order they're written. So in your example you're probably applying the new line breaks with nl2br and then removing them again with hacksaw.

Try:

<p>{{ workItem.summary | hacksaw(words='75', append='...') | nl2br }}</p>

Alternatively you could try setting hacksaw to allow line break tags. Something like this (untested):

<p>{{ workItem.summary | nl2br | hacksaw(words='75', append='...', allow='<br>') }}</p>

I'd go with the first option though.

1
  • Thanks for your time and answer, I realized after continuing to play with this that I do not need to add the function I was trying to add. My issue is comes from adding "hacksaw" to the text is breaking the formatting, I was trying to solve by adding in the nl2br function but I was just misunderstanding the issue. Feb 15 '16 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.