Closed daedalus28 closed 9 years ago
It's worth pointing out that {{# if }}
works, so it's no big deal - we'll just move to that style as I think I like that better anyway. It is, however, a breaking change and should either be fixed or documented somewhere. Before we upgrade to 0.5 we will need to fix all the places that use the old style, which thankfully isn't as daunting as it could be if we had already migrated all of our old virtual comment stuff to use the new syntax.
As a side note, some mobile carriers and even some corporate firewalls can apparently sometimes strip html comments in certain cases, so this library is more than just syntax sugar. Might help rationalize the inclusion of it to the KO core, though it is an edge case.
I would also say that this can be an issue.
Several popular server-side template languages (e.g. Jinja2 & Django) use {#
for comments. This can make it rather difficult to use Punches with them.
Most of these server-side languages have options to change the syntax styles, but that may be laborious for existing code bases.
The solution looks (to my naive eyes) to be to call trim(expressionText)
in wrapExpression
before lastChar
and firstChar
are determined.
We're using the interpolation syntax for bindings like if and foreach instead of virtual comments, and prefer to put a space between the '{{' and the '#'. This worked great in the previous version, but broke with the recent release of 0.5.
As a specific example,
{{#if }}
works, but{{ #if }}
does not.I've put together a jsfiddle showing the bug: http://jsfiddle.net/daedalus28/nf5wkahj/