# babel-plugin-htmlbars-inline-precompile

> Babel plugin to replace tagged template strings with precompiled HTMLBars templates

Latest version **5.3.1** (published 2021-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-htmlbars-inline-precompile
pnpm add babel-plugin-htmlbars-inline-precompile
yarn add babel-plugin-htmlbars-inline-precompile
bun add babel-plugin-htmlbars-inline-precompile
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.3.1 |
| Published | 2021-10-26 |
| First published | 2015-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 10.* \|\| >= 12.* |
| Dependencies | 5 |
| Unpacked size | 76.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Clemens Müller |
| Maintainers | rwjblue, turbo87, stefanpenner, ember-cli |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-htmlbars-inline-precompile
- Repository: https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile
- Homepage: https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile#readme
- Issues: https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile/issues
- npm.io page: https://npm.io/package/babel-plugin-htmlbars-inline-precompile

## Dependencies (5)

- [line-column](https://npm.io/package/line-column.md) ^1.0.2
- [magic-string](https://npm.io/package/magic-string.md) ^0.25.7
- [parse-static-imports](https://npm.io/package/parse-static-imports.md) ^1.1.0
- [string.prototype.matchall](https://npm.io/package/string.prototype.matchall.md) ^4.0.5
- [babel-plugin-ember-modules-api-polyfill](https://npm.io/package/babel-plugin-ember-modules-api-polyfill.md) ^3.5.0

## Recent versions

- 5.3.1 (latest) — 2021-10-26
- 5.3.0 — 2021-04-12
- 5.2.2 — 2021-04-01
- 5.2.1 — 2021-03-24
- 5.2.0 — 2021-03-24
- 5.1.0 — 2021-03-23
- 5.0.0 — 2021-03-17
- 4.4.6 — 2021-03-17
- 4.4.5 — 2021-03-12
- 4.4.4 — 2021-02-25
- 4.4.3 — 2021-02-24
- 4.4.2 — 2021-02-24
- 4.4.1 — 2021-02-24
- 4.4.0 — 2021-02-23
- 4.3.0 — 2021-02-22
- … 27 more at https://npm.io/package/babel-plugin-htmlbars-inline-precompile/versions

## README

# babel-plugin-htmlbars-inline-precompile

<a href="https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile"><img alt="Build Status" src="https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile/workflows/CI/badge.svg"></a>

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:

```js
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):

```js
import hbs from 'htmlbars-inline-precompile';

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

## Babel Plugin Usage

``` js
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

``` js
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

``` js
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!');
  });
});
```

---
_Source: https://npm.io/package/babel-plugin-htmlbars-inline-precompile · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
