tildeio / htmlbars

A variant of Handlebars that emits DOM and allows you to write helpers that manipulate live DOM nodes
MIT License
1.6k stars 193 forks source link

Peculiar Treatment of Comments #465

Open jszaday opened 8 years ago

jszaday commented 8 years ago

I noticed something peculiar about the way htmlbars is treating comments; however, I am not sure if it is a bug or by design. I first noticed this when I commented out the link-to beginning and end tags around a line of code like so:

    <!-- {{#link-to 'group' group}} -->
    {{group.name}}
    <!-- {{/link-to}} -->

When I went to look at the live preview, I expected to see the group names; instead I didn't see them and when I inspected the page, I saw this. It seems like htmlbars is treating the two separate comments as one large comment and ignoring the content between them. This is not a big deal since it's easily fixed by moving the {{group.name}} line before the commented out link-to statement (like so) but I thought I'd post it here, just in case.

mmun commented 8 years ago

Looks like a bug.

On the flip side, you can use Handlebars comments {{!-- foo --}} which should not have this problem. You shouldn't use unless you want to preserve the comments in the compiled template.

jszaday commented 8 years ago

Alright, duly noted. I was not aware those are a thing and my editor (Atom) just auto inserts HTML-style comments when using the comment keyboard macro (Ctrl+/); perhaps I should look into updating their handlebars plugin as well, haha.