Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alfonsobries's avatar

Use a filter (custom filter) in v-html property

I have a filter that converts line breaks to html, in previous versions normally i use the filter like this:

{{ description | nl2br }}

That actually works but the html its escaped, so doesn't show as HTML, the triple mustach doesn't work {{{ description | nl2br }}} (seems that its deprecated)

so i found in the documentation the v-html="" that works with html string but when i apply the filter it doesn't work, i didnt found the syntax o how can achieve that:

<p v-html="description|nl2br"></p>
// this doesn't work returns: Property or method "nl2br" is not defined on the instance but referenced during render

Any idea?

0 likes
3 replies
alfonsobries's avatar
alfonsobries
OP
Best Answer
Level 9

Just find a solution:

<p v-html="this.$options.filters.nl2br(description)"></p>
3 likes

Please or to participate in this conversation.