Let's say I have:
@string = "it is a <a href="#">string</a>"
I want to use it in different parts of my application in two ways:
The first one can be done using html_safe
:
@string.html_safe
It is a string
How can I achieve the second one?
It is a string.
You can try this:
ActionView::Base.full_sanitizer.sanitize(@string)
See strip_tags(html).
You can try this:
strip_tags(@string)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With