Open jslegers opened 10 years ago
I think that {{!-- }} comments are not supported at all; only {{! expression }} style comments are supported.
I think this should be implemented in src/Handlebars/Tokenizer.php
.. if I have time to study the library I'll fix that!
@jslegers the original comments syntax is {{! This is a comment }}
. Moreover a comment cannot contain closing stashes (}}
).
In your last example anything after the first }}
token is treated as a template, not as a comment. I think that you have not registered in_ca
helper, that's why you've got an exception.
I believe that Handlebars.php behavior is correct and correspond to Handlebars.js behavior.
Handlebars.js allows comments that contain handlebar tokens with the {{!-- --}}
syntax, and looks like that functionality has been there since at least 2013. Has this still not been implemented in Handlebars.php?
+1 for comments.
It's unclear to me whether it's possible to comment out expressions and have handlebars.php completely ignore anything in a comment, which is possible in pretty much every programming language and commonly used for temporarily storing deleted code that may be fully or partially restored at a later time.
Currently, handlebars.php tries to parse any
{{ }}
it can find as an expression, including those within comments. This results in a fatal error when no helper can be found with that name.That means I can't do this :
This also doesn't work :
This doesn't work either :
Neither does this :
Whatever I try, I keep getting the following error :
This isn't how I expect comments to work.