Reputation: 35
I want use the F3::clean
function in a template but it doesn't work. The function doesn't remove HTML tags. When I use function in controller, everything is working fine.
{{ F3::clean(@servisItem.description, 'br') | raw }}
I want to display servisItem.description
with <br>
and any other
HTML code removed.
How can I do this?
Upvotes: 1
Views: 106
Reputation: 3908
That's because variables passed to the template are HTML-escaped. Therefore there's no more any HTML tag to be stripped. See:
<p>foo<br>bar</p>
<p>foo<br>bar</p>
The best is to strip tags inside the controller, but if you absolutely need to do it inside the template, then you need to unstrip tags first:
{{ F3::clean(F3::decode(@servisItem.description), 'br') }}
Upvotes: 1