New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Truncating text not working?

Peter Emil van den Berg November 29, 2018 by Peter Emil van den Berg

Hi all. Just a quick question. I've got a summary based on the Redwood theme where I truncate text and put an ellipsis afterwards. Client can fill in using Bard field type so they can set text in bold and italic. Now there is (not always) a
in their text. I want that stripped out, but it seems it is not working... :(

I tried several options, and when using {{ summary | strip_tags:true }} in the template all stripping is done OK, but when using {{ summary | strip_tags:em|strong|br }} only the first tag is stripped, not the other two. Using {{ summary | macro:summary }} and defining it in the macro.yaml works the same: so it is basically an all or nothing setting...


title: Effe snel wat in elkaar geflanst
summary: '<p>Dido Dido is na een <em>succesvolle</em> tournee door Nederland nog <strong>eenmalig</strong> te zien tijdens de Operadagen Rotterdam op 25 mei<br></p>'


    type: bard
    display: Summary
    instructions: 'Has a twofold purpose: acts as the introduction paragraph while being the summary in the news carousel on the homepage. Keep it short & sweet.'
    localizable: true
    spellcheck: true
    style: serif
    semantic_elements: true
      - bold
      - italic


<div class="summary">
    <h3>{{ title }}</h3>
    <p>{{ summary | macro:summary }}</p>


  strip_tags: em|strong|br
  safe_truncate: 100
  ensure_right: ...

looks very solid to me :smiley:

Answered by Peter Emil van den Berg!
>>>>>>> Answered <<<<<<<
1 Reply
1 Follower