4 ms·
But it's a lot of syntactic sugar. There's a second, stringly-typed language embedded in your HTML template.
by ng12 8y ago
But it's a lot of syntactic sugar. There's a second, stringly-typed language embedded in your HTML template.
- mattigames 8y agoThe only reason for it to be "stringly-typed" is that your IDE doesn't support it.
- ng12 8y agoIt's still stringly typed even if someone wrote an IDE plugin that tries very hard to make it safe.
- nv-vn 8y agoAt the end of the day, it's much more of a hack. The IDE having to guess at what the string does is ridiculous to me, and it's just a ton of extra work for the person who wrote the IDE for no real reason. And now if you want to embed a string inside you need to switch quotes. Plus formatting gets super weird if you have a multiline condition. It's also super confusing for new users. There are so many issues I see with that design that I can't begin to understand why someone would argue in favor of it.
- lucidone 8y agoA lot of people are familiar with it (and that style) via AngularJS. It may not be as pure, but it's what they know.
- mattigames 8y agoAn IDE doesn't have to guess anything, if the string is preceded by v-if then is code, that's it. Pretty much how a string literal inside eval() could be parsed as code.
- nv-vn 8y agoWhat if another library uses v-if? Or there's no library loaded at all? What if I just wrote a new library that uses c-if? I imagine most IDEs approach this by looking at the string and trying to guess whether it's HTML code or not.