flashios09 / extract-tagged-template-literals

Search and extract tagged template literals from javascript/typescript file.
1 stars 1 forks source link

Support for `hbs('template-here')`? #2

Open rwjblue opened 4 years ago

rwjblue commented 4 years ago

Does this library currently support usage without tagged template literals? Given the name, I'd assume it doesn't but wanted to check in...

In general, the underlying babel plugin that is used by Ember apps supports all of the following:

import { hbs } from 'ember-cli-htmlbars'

hbs`some template here`

hbs('some template here');

hbs('some template here', { moduleName: 'zomg.hbs' });
flashios09 commented 4 years ago

Does this library currently support usage without tagged template literals?

No it doesn't, only the tagged template literals (back-tick format) is supported

the underlying babel plugin that is used by Ember apps supports all of the following

Why/when we use those formats for inline templates ?

hbs('some template here');
hbs('some template here', { moduleName: 'zomg.hbs' });
rwjblue commented 4 years ago

The most common reason to use the CallExpression form is when you'd need to pass additional metadata. In the example snippet above I pass the moduleName for the template, which is quite important in some cases (e.g. if your translation system uses the template name itself as a key).

flashios09 commented 4 years ago

which is quite important in some cases

So i think we need to create a new package ember-extract-inline-templates that supports those formats What do you think ?