Package Exports
- ember-cli-htmlbars-inline-precompile
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ember-cli-htmlbars-inline-precompile) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ember-cli-htmlbars-inline-precompile
Precompile template strings within the tests of an Ember project via tagged template strings:
// ember-cli-project/test/unit/components/my-component-test.js
import { module, test } from 'qunit';
import { render } from '@ember/test-helpers';
import { setupRenderingTest, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
module('my-component', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
await render(hbs`hello ember testing!`);
assert.equal(this.element.innerText, 'hello ember testing!');
});
});
Requirements
- Ember 2.12+
- Node 8+
- Babel 7+
Installation
Install the addon via ember install ember-cli-htmlbars-inline-precompile
Caveats
Keep in mind that the source files are transformed, so the inline template
definitions are replaced with Ember.HTMLBars.template(…)
statements. This
means that you can't do fancy stuff like string interpolation within the
templates:
test('string interpolation within templates is NOT supported', async function(assert) {
let valuePath = 'greeting';
await render(hbs`
${valuePath}: <span>{{value}}</span>
`);
// the template will be "${valuePath}: <span>{{value}}</span>"
});
If you need stuff like this, you need to include ember-template-compiler.js
in your test-build and use Ember.HTMLBars.compile("…")
within your tests.