# broccoli-underscore-template-compiler

> Broccoli plugin to compile Underscore templates to ES6 modules.

Latest version **0.2.0** (published 2018-12-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install broccoli-underscore-template-compiler
pnpm add broccoli-underscore-template-compiler
yarn add broccoli-underscore-template-compiler
bun add broccoli-underscore-template-compiler
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-12-05 |
| First published | 2014-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 6.* \|\| 8.* \|\| >= 10.* |
| Dependencies | 2 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dan Freeman |
| Maintainers | dfreeman |
| Keywords | broccoli-plugin, underscore, template |

## Links

- npm: https://www.npmjs.com/package/broccoli-underscore-template-compiler
- Repository: https://github.com/salsify/broccoli-underscore-template-compiler
- npm.io page: https://npm.io/package/broccoli-underscore-template-compiler

## Dependencies (2)

- [lodash-node](https://npm.io/package/lodash-node.md) ^2.4.1
- [broccoli-persistent-filter](https://npm.io/package/broccoli-persistent-filter.md) ^2.1.1

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2018-12-05
- 0.1.0 — 2014-10-15

## README

# Broccoli Underscore Template Compiler

## Installation

```bash
npm install -D broccoli-underscore-template-compiler
```

## Example

```javascript
var compileTemplates = require('broccoli-underscore-template-compiler');

var templatesTree = compileTemplates('templates', {
  description: 'TemplateCompiler (appTemplates)'
});
```

## Input Format

Given the following input:

```html
<template id="firstTemplate" data-notes="This is my first template">
  <%- message %>
</template>
```

This plugin will produce an ES6 module equivalent to:

```javascript
export var firstTemplate = _.extend(_.template('\n  <%- message %>\n'), {
  metadata: {
    notes: 'This is my first template'
  }
});

export default {
  firstTemplate: firstTemplate
};
```

Each `<template>` in the source file will be available as a field in the module's
default export, as well as an exported variable of the same name, with any data
attributes on the template available under a `metadata` hash hanging off of the
resulting function.

## Usage

The templates produced by this filter are just the output of Underscore's `_.template` function, so you can use them as [their documentation](http://underscorejs.org/#template) suggests:

```js
var helloTemplate = _.template("hello: <%= name %>");
helloTemplate({ name: 'moe' });
//=> "hello: moe"
```

The exported template function is exposed from the compiled module, e.g.

```html
<!-- templates/my-templates.html -->
<template id="helloTemplate">hello: <%= name %></template>
```

```js
import { helloTemplate } from 'templates/my-templates';
helloTemplate({ name: 'moe' });
//=> "hello: moe"
```

## Configuration

### `compileTemplates(inputTree, options)`

---

`options.extensions` *{Array}* (Optional, default `['html']`)

The file extensions which should be read and compiled as templates.

## License

This project is distributed under the MIT license.

---
_Source: https://npm.io/package/broccoli-underscore-template-compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
