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

Ensure inline precompilation does not error when a template contains */ #392

Merged
merged 1 commit into from
Dec 12, 2019

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Dec 11, 2019

Update babel-plugin-htmlbars-inline-precompile to 3.0.1 to fix an issue with inline templates containing */.

Prior to this a template like:

hbs`some content */`

Would emit invalid JS:

Ember.HTMLBars.template(
  /*
    some content */
  */
  {
    // some stuff emitted by actual compilation
  }
)

The comment showing the original template was added as a developer aide (makes looking at files with many inline templates such as tests much easier), but without escaping */ we risk the template content itself breaking the JS parsing within the file.

This commit ensures that */ is escaped to *\/ which avoids the issue.

Fixes #391

@rwjblue rwjblue added the bug label Dec 11, 2019
@rwjblue rwjblue changed the title Update babel-plugin-htmlbars-inline-precompile to 3.0.1. Ensure inline precompilation does not error when a template contains */ Dec 11, 2019
Prior to this a template like:

```js
hbs`some content */`
```

Would emit invalid JS:

```js
Ember.HTMLBars.template(
  /*
    some content */
  */
  {
    // some stuff emitted by actual compilation
  }
)
```

The comment showing the original template was added as a
developer aide (makes looking at files with many inline
templates such as tests much easier), but without
escaping `*/` we risk the template content itself
breaking the JS parsing within the file.

This commit ensures that `*/` is escaped to `*\/` which
avoids the issue.
@rwjblue rwjblue force-pushed the update-babel-plugin branch from d30ae7f to eb2d165 Compare December 12, 2019 14:09
@rwjblue rwjblue merged commit ce55123 into master Dec 12, 2019
@rwjblue rwjblue deleted the update-babel-plugin branch December 12, 2019 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<style> tags with CSS comments cause invalid compilation
1 participant