imcvampire / vue-truncate-filter

A filter for Vuejs to truncate string
MIT License
57 stars 6 forks source link

how use with v-html? #9

Closed andysay closed 6 years ago

andysay commented 6 years ago

Hi author ! how use with v-html?

v-html="message.content || truncate(50) "> not work, thanks!

imcvampire commented 6 years ago

Have you try v-html="message.content | truncate(50)" (only 1 |)?

andysay commented 6 years ago

yeah, i'm try , but not work ;(

pexea12 commented 6 years ago

You cannot use vue-truncate-filter with v-html: https://github.com/vuejs/vue/issues/4352#issuecomment-263976170

You can truncate your message before putting in v-html via: this.$options.filters.truncate(message.content, 50)

kakulukia commented 6 years ago

Why this inconsistency where i can use filter in bindings (https://vuejs.org/v2/guide/filters.html#ad) but am not able to use it in v-html or v-text?

imcvampire commented 6 years ago

You can read about it https://vuejs.org/v2/guide/migration.html#Filters-Outside-Text-Interpolations-removed

kakulukia commented 6 years ago

okay, got it .. but why is the old/removed filter syntax still inside the docs (see the link i posted above)?

thx for answering!

imcvampire commented 6 years ago

@kakulukia It still there, but do not apply to v-html anymore!

kakulukia commented 6 years ago

its very sad, tho :/