Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducing confusion around HTML comments and Glimmer blocks #1395

Open
davidtaylorhq opened this issue Oct 3, 2022 · 0 comments
Open

Reducing confusion around HTML comments and Glimmer blocks #1395

davidtaylorhq opened this issue Oct 3, 2022 · 0 comments

Comments

@davidtaylorhq
Copy link

davidtaylorhq commented Oct 3, 2022

Normally, glimmer syntax inside HTML comment tags is not evaluated:

<!-- {{this.someProperty}} -->
<div>Hello World</div>

This is rendered out to the browser as:

<!-- {{this.someProperty}} -->
<div>Hello World</div>

Makes sense 馃憣

However, if the glimmer syntax inside the HTML comment is a block opening:

<!-- {{#if someCondition}} -->
<div>Hello World</div>
<!-- {{/if}} -->

Then the entire content of the block is made into an HTML comment. Here's a screenshot from the chrome dev tools:

This difference in behaviour between non-blocks and blocks is quite confusing. It's especially confusing because syntax highlighters do not indicate that <div>Hello World</div> is commented-out.

The 'best-practice' here is to use the handlebars comment syntax rather than HTML comments. However, HTML comments may be automatically inserted by badly-configured editors, or by people who are less familiar with Glimmer/HBS.

In discussions with @wycats, he suggested that changing the behaviour here in a backwards-compatible way would be difficult. However, it may be possible to make this 'open block in an HTML comment' an opt-in deprecation warning, or maybe even a syntax error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant