vendredi 26 mars 2021

How to remove tags from strings in html file?

For example if my field contains

description: "<p>Some Text </p>"

and I display it in my html.erb file as item.description How can I remove this p tags?

  <div class="preview__text">
          <%= sanitize(item.description) %>
        </div>

or

  <div class="preview__text">
          <%= item.description.html_safe %>
        </div>

Aucun commentaire:

Enregistrer un commentaire