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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(templates): replace HTML comments with HBS ones #4681

Merged
merged 1 commit into from Feb 15, 2022

Conversation

ilhan007
Copy link
Member

@ilhan007 ilhan007 commented Feb 1, 2022

Replaces the HTML comments inside the HBS templates with HBS comments as suggested in the related issue and following the official docs. The HBS comments are stripped from the output and are available only to developers at DEV time, while the HTML ones are part of the output and could be observed in the browser. After this change only the lit-html comments can be seen.

Previously (the comment is part of the lit template)

const block0 = (context, tags, suffix) => html`<div class="ui5-panel-root"><!-- header: either header or h1 with header text --><div @click="${context._headerClick}"

After (the comment is removed)

const block0 = (context, tags, suffix) => html`<div class="ui5-panel-root"><div @click="${context._headerClick}"

As the related issue suggests, I went trough the list of tasks:

CommentStatement: function(/* comment */) {},
  • add support for hbs comments, if necessary - have not found issues so far, HBS comments work as expected
  • use hbs comments everywhere (fix all current templates) - done with the change

Related to: #2802

@ilhan007 ilhan007 merged commit ddc38eb into master Feb 15, 2022
@ilhan007 ilhan007 deleted the fix-template-comments branch February 15, 2022 13:28
ilhan007 added a commit that referenced this pull request Mar 18, 2022
Replaces the HTML comments inside the HBS templates with HBS comments as suggested in the related issue and following the [official docs](https://handlebarsjs.com/examples/comments.html). The HBS comments are stripped from the output and are available only to developers at DEV time, while the HTML ones are part of the output and could be observed in the browser. After this change only the lit-html comments can be seen.

Previously (the comment is part of the lit template)

```js
const block0 = (context, tags, suffix) => html`<div class="ui5-panel-root"><!-- header: either header or h1 with header text --><div @click="${context._headerClick}"
```
After (the comment is removed)

```js
const block0 = (context, tags, suffix) => html`<div class="ui5-panel-root"><div @click="${context._headerClick}"
```

As the related issue suggests, I went trough the list of tasks:

- [ ] investigate the hbs2lit script's handling of comments  - we can look at this more closely, so far haven't found anything specific to comments, the following [line] somehow seems relevant at least it has "comment" in the name (https://github.com/SAP/ui5-webcomponents/blob/master/packages/tools/lib/hbs2lit/src/partialsVisitor.js#L95)
```js
CommentStatement: function(/* comment */) {},
```


- [X] add support for hbs comments, if necessary - have not found issues so far, HBS comments work as expected
- [x] use hbs comments everywhere (fix all current  templates) - done with the change

Related to: #2802
@ilhan007 ilhan007 mentioned this pull request Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants