BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.
http://www.jsviews.com
MIT License
2.68k stars 340 forks source link

Data linking, syntax error when commented #330

Closed alnico2001 closed 7 years ago

alnico2001 commented 7 years ago

Syntax error returned when comment added to data linked: {^{!--...

Minor issue ;-)

BorisMoore commented 7 years ago

{{!-- xxx --}} is correct but {^{!-- xxx --}} is indeed a syntax error. Did you think that should be valid syntax?

alnico2001 commented 7 years ago

Sorry. Yes, if I can comment out {{!-- then why not {^{!-- One of the same to me.

BorisMoore commented 7 years ago

Ah - well in my thinking, a comment tag is a different tag altogether, and it is not a question of 'commenting out' some other tag. I guess your idea is that you can take any tag such as {^{:foo}} and temporarily change it to {^{!--:foo--}} by adding !-- and -- at the beginning and end.

In my process I would wrap the whole thing (one or more tags, or other markup) like this: {{!-- {^{:foo}} --}}, rather than converting individual tags to a 'commented out' form.

Not sure I want to support {^{!-- ... --}} since it means there are two different syntaxes for a comment tag and/or there is a concept of a 'data-linked' comment tag (as opposed to an un-data-linked comment tag) - but in fact comment tags cannot be data-linked. If they could it would imply an instance of a data-linked comment tag, and a life-cycle of events, including dispose... Comment tags are simply removed from the rendered output. They are no longer there when the data-linking phase happens.

alnico2001 commented 7 years ago

Ah yes, the more I think about it...I agree, they are different. And indeed I do wrap {{!-- {^{:foo}} --}} as you've suggested.

It is such a minor thing anyway; so I am completely fine the way it is. Thanks.

Great library by the way!