Vue: Compilation of mustaches in mustaches expression doesn't work

Created on 9 Apr 2018  路  6Comments  路  Source: vuejs/vue

Version

2.5.16

Reproduction link

https://jsfiddle.net/9bzw21no/33/

Steps to reproduce

  1. Use a string literal containing }} in the data binding
{{ 'hello}}' + '{{world' }}

What is expected?

hello}}{{world

What is actually happening?

hello)+""+_s(world


I expected the same result as svelte.

All 6 comments

Please don't open duplicate issues. It's not an obligation for framework X to support the same behavior as framework Y.

You can also use v-text or escape codes ('x7bx7b', 'x7dx7d')

@posva thank you

but I'm very disappointed

Think about it as a tradeoff for maintainability. Supporting mustaches inside mustaches would increase the complexity of the code (the parser), which means other possible bugs, while it's very uncommon to use plain strings with mustaches inside mustaches and very easy to workaround -> use a variable (computed property: probably most common use case), v-text or js escape the character. Using a computed property will make your code more maintainable and in some situations faster 馃檪

Just use {{ '\}\}' }}...

ha, allow me to express my surprise here, too. 'hello}}' + '{{world' is a perfectly valid expression, just a string concatenation! How come what looks like mustaches inside a string triggers bad parsing in the engine! Don't get me wrong, I am and really hope to continue to be very a happy vue.js user, but couldn't help adding my 0.02 here. Keep up the great work team.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karevn picture karevn  路  36Comments

yyx990803 picture yyx990803  路  36Comments

rpkilby picture rpkilby  路  50Comments

karevn picture karevn  路  42Comments

wenLiangcan picture wenLiangcan  路  39Comments