BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
856 stars 130 forks source link

'~' operator in templates #403

Closed Mytia closed 5 years ago

Mytia commented 6 years ago

As I understand the first '~' operator is ignored. It also does not work correctly for object properties without brackets.

https://jsfiddle.net/nq4372t8/68/

BorisMoore commented 6 years ago

Hi Mytia.

Yes, that is true - the ~ operator is not supported in template expressions. But here is a possible update, which could support it.

jsviews.js.txt

How does that work for you? It should now support ~(x) ~ x and for contextual parameters, ~y you can write ~(~y) or ~ ~y or ~~y

I'm not sure what you mean by It also does not work correctly for object properties without brackets.. Can you give an example?

Mytia commented 6 years ago

New version works fine. I just mean that ~(x) works but ~x don't (without space). ~ ~x can be breaking after templates minification, so in production better to use brackets.

BorisMoore commented 6 years ago

Yes ~x is assumed to be a helper. To use the ~ operator on a non-helper path such as x, you need to write ~ x or ~(x).

~ ~x shouldn't break on minification since it is not within javascript code. It is within the template, so either a string (of HTML markup) or within a script block. In both cases, white-space is preserved. And the compiled template will not include that ~ ~x string, and should minify fine...

BorisMoore commented 5 years ago

This has been fixed in release v0.9.91.