Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

babel-plugin-htmlbars-inline-precompile

ember-cli678.9kMIT5.3.1

Babel plugin to replace tagged template strings with precompiled HTMLBars templates

readme

babel-plugin-htmlbars-inline-precompile

Build Status

Babel plugin to replace tagged .hbs formatted strings with a precompiled version.

Requirements

  • Node 8+
  • Ember 2.10+
  • Babel 7

Usage

Can be used as either a normal function invocation or a tagged template string:

import hbs from 'htmlbars-inline-precompile';

hbs`some {{handlebarsthingy}}`;
hbs('some {{handlebarsthingy}}');

When used as a normal function invocation, you can pass additional options (e.g. to configure the resulting template's moduleName metadata):

import hbs from 'htmlbars-inline-precompile';

hbs('some {{handlebarsthingy}}', { moduleName: 'some/path/to/file.hbs' });

Babel Plugin Usage

var HTMLBarsCompiler = require('./bower_components/ember/ember-template-compiler');
var HTMLBarsInlinePrecompile = require('babel-plugin-htmlbars-inline-precompile');

require('babel').transform("code", {
  plugins: [
    [HTMLBarsInlinePrecompile, {precompile: HTMLBarsCompiler.precompile}],
  ],
});

Example

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module("my component", function(hooks) {
  setupRenderingTest(hooks);

  test('inline templates ftw', async function(assert) {
    await render(hbs`hello!`);

    assert.dom().hasText('hello!');
  });
});

results in

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module("my component", function(hooks) {
  setupRenderingTest(hooks);

  test('inline templates ftw', async function(assert) {
    await render(Ember.HTMLBars.template(function() {
      /* crazy HTMLBars template function stuff */
    }));

    assert.dom().hasText('hello!');
  });
});

changelog

v5.3.0 (2021-04-12)

:rocket: Enhancement

:house: Internal

Committers: 2

v5.2.2 (2021-04-01)

:bug: Bug Fix

Committers: 1

v5.2.1 (2021-03-24)

:bug: Bug Fix

  • #368 Account for comments in preprocessor for proposals (@pzuraq)

Committers: 1

v5.2.0 (2021-03-24)

:rocket: Enhancement

  • #361 Add preprocessEmbeddedTemplates function (@pzuraq)
  • #362 Allow usage of proposals to be used in arbitrary expression positions (@pzuraq)

Committers: 1

v5.1.0 (2021-03-23)

:rocket: Enhancement

  • #360 Add ability to parse scope function (allow strict mode templates to be more resilient to module cycles). (@pzuraq)

:bug: Bug Fix

  • #359 Ensure locals are used instead of scope everywhere (@pzuraq)

Committers: 1

v5.0.0 (2021-03-17)

:boom: Breaking Change

  • #358 Rename scope to locals for strict mode transpilation (@pzuraq)

:rocket: Enhancement

Committers: 1

v4.4.6 (2021-03-17)

:bug: Bug Fix

  • #357 [BUGFIX] Use a unique identifier for each reference (@pzuraq)

Committers: 1

v4.4.5 (2021-03-12)

:bug: Bug Fix

  • #355 Avoid sharing list of previously added imports. (@rwjblue)

Committers: 1

v4.4.4 (2021-02-25)

:bug: Bug Fix

Committers: 1

v4.4.3 (2021-02-24)

:bug: Bug Fix

Committers: 1

v4.4.2 (2021-02-24)

:bug: Bug Fix

  • #347 Default ensureModuleApiPolyfill to true (@pzuraq)

Committers: 1

v4.4.1 (2021-02-24)

:bug: Bug Fix

  • #346 Ensure proposal syntaxes work with Ember module API polyfill (@pzuraq)

Committers: 1

v4.4.0 (2021-02-23)

:rocket: Enhancement

  • #339 Add moduleOverrides options (@pzuraq)
  • #338 Refactor to use createTemplateFactory (@pzuraq)
  • #336 Implements an option to support the template tag imports proposal (@pzuraq)

Committers: 1

v4.3.0 (2021-02-22)

:rocket: Enhancement

  • #335 Implements an option to support the template literal imports proposal (@pzuraq)
  • #334 Add support for multiple imports (@pzuraq)
  • #333 [FEAT] Add shouldParseScope, disableTemplateTag, disableFunctionCall options (@pzuraq)
  • #332 Adds useEmberModule option (@pzuraq)

Committers: 1

v4.2.1 (2020-11-09)

:bug: Bug Fix

  • #297 Fix issues when using emoji in templates while transpiling for IE11 (@rwjblue)

Committers: 1

v4.2.0 (2020-08-10)

:rocket: Enhancement

Committers: 2

v4.1.0 (2020-05-07)

:rocket: Enhancement / :bug: Fix

  • #216 Avoid assuming ember-template-compiler result is JSON (@rwjblue)

Committers: 1

v4.0.1 (2020-05-06)

:bug: Bug Fix

Committers: 1

v4.0.0 (2020-05-06)

:boom: Breaking Change

:house: Internal

  • #211 Update release automation dependencies and settings. (@rwjblue)

Committers: 2

v3.1.0 (2020-05-06)

:rocket: Enhancement

  • #208 Add ability to transfer compilation errors into runtime. (@rwjblue)

:house: Internal

Committers: 2

v3.0.1 (2019-12-11)

:bug: Bug Fix

  • #134 Ensure */ included in a template does break surrounding JS. (@rwjblue)

Committers: 1

v3.0.0 (2019-10-01)

  • Released in order to avoid incompatibilities between ember-cli-htmlbars and ember-cli-htmlbars-inline-precompile. Contains no changes from prior version.

v2.1.1 (2019-09-29)

:bug: Bug Fix

  • #104 Ensure JSON.stringify'ed value is valid for hbs() options. (@rwjblue)

Committers: 1

v2.1.0 (2019-09-09)

:rocket: Enhancement

Committers: 2

v2.0.0 (2019-08-30)

:boom: Breaking Change

:rocket: Enhancement

  • #89 Add an inline comment with the original template. (@rwjblue)
  • #75 Add ability to pass static options to transpilation. (@rwjblue)
  • #42 Test templates from MU co-located tests (@NullVoxPopuli)

:memo: Documentation

:house: Internal

Committers: 5

v0.2.5 (2018-06-02)

Full Changelog

Implemented enhancements:

  • Pass through content to precompile. #37 (rwjblue)

Merged pull requests:

v0.2.4 (2018-03-22)

Full Changelog

Implemented enhancements:

Merged pull requests:

v0.1.1 (2017-07-21)

Full Changelog

Implemented enhancements:

  • CI: Use "auto-dist-tag" for deployment #24 (Turbo87)

Merged pull requests:

v0.2.3 (2017-03-13)

Full Changelog

Merged pull requests:

  • Avoid error when processing expressions before import has ocurred. #23 (rwjblue)

v0.2.2 (2017-03-13)

Full Changelog

Merged pull requests:

  • Add failing test for usage after modules transform. #22 (rwjblue)

v0.2.1 (2017-03-11)

Full Changelog

Merged pull requests:

  • Refactor to work when before babel-plugin-transform-es2015-template-literals. #21 (rwjblue)

v0.2.0 (2017-03-11)

Full Changelog

Closed issues:

  • An in-range update of babel-core is breaking the build 🚨 #18
  • needs to support caching #17

Merged pull requests:

  • Add basic caching for babel@6 usage. #20 (rwjblue)
  • CI: Enable automatic NPM deployment for tags #19 (Turbo87)

v0.1.0 (2016-08-10)

Full Changelog

Implemented enhancements:

  • will be improved by #3
  • Cleanup & referencesImport() #13 (Turbo87)

Closed issues:

  • Migrate to ember-cli org? #14
  • placeholders inside a tagged template string are not supported #9

Merged pull requests:

0.0.5 (2015-07-10)

Full Changelog

Merged pull requests:

  • Allow single string as argument for hbs #7 (pangratz)

0.0.4 (2015-06-30)

Full Changelog

v0.0.3 (2015-06-26)

Full Changelog

Closed issues:

  • Babel deprecation with 5.6.14 - Use path.replaceWithSourceString. #5

Merged pull requests:

  • Use path.replaceWithSourceString to avoid deprecation. #6 (rwjblue)

v0.0.2 (2015-06-13)

Full Changelog

Merged pull requests:

  • Replace remove() with dangerouslyRemove() #4 (alisdair)

v0.0.1 (2015-05-06)

* This Change Log was automatically generated by github_changelog_generator