# mustache-loader

> Mustache loader for webpack

Latest version **1.4.3** (published 2019-02-09) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install mustache-loader
pnpm add mustache-loader
yarn add mustache-loader
bun add mustache-loader
```

## 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 | 1.4.3 |
| Published | 2019-02-09 |
| First published | 2014-09-18 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 3 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 38 |
| Author | Kir Belevich |
| Maintainers | baderbuddy, deepsweet |
| Keywords | webpack, loader, mustache, hogan |

## Links

- npm: https://www.npmjs.com/package/mustache-loader
- Repository: https://github.com/deepsweet/mustache-loader
- Issues: https://github.com/deepsweet/mustache-loader/issues
- npm.io page: https://npm.io/package/mustache-loader

## Dependencies (3)

- [hogan.js](https://npm.io/package/hogan.js.md) ^3.0.2
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0
- [html-minifier](https://npm.io/package/html-minifier.md) ^3.1.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.4.3 (latest) — 2019-02-09
- 1.4.1 — 2018-07-05
- 1.4.0 — 2018-01-29
- 1.3.1 — 2018-01-27
- 1.2.0 — 2017-09-21
- 1.0.0 — 2017-07-02
- 0.4.1 — 2016-12-10
- 0.4.0 — 2016-10-05
- 0.3.3 — 2016-09-13
- 0.3.2 — 2016-09-12
- 0.3.1 — 2015-12-11
- 0.3.0 — 2015-03-07
- 0.2.0 — 2014-10-04
- 0.1.4 — 2014-09-25
- 0.1.3 — 2014-09-19
- … 3 more at https://npm.io/package/mustache-loader/versions

## README

## Mustache loader for [webpack](https://webpack.github.io/)

[![npm](http://img.shields.io/npm/v/mustache-loader.svg?style=flat-square)](https://www.npmjs.org/package/mustache-loader)
[![travis](http://img.shields.io/travis/deepsweet/mustache-loader.svg?style=flat-square)](https://travis-ci.org/deepsweet/mustache-loader)
[![climate](http://img.shields.io/codeclimate/github/deepsweet/mustache-loader.svg?style=flat-square)](https://codeclimate.com/github/deepsweet/mustache-loader/code)
[![peer deps](http://img.shields.io/david/peer/deepsweet/mustache-loader.svg?style=flat-square)](https://david-dm.org/deepsweet/mustache-loader#info=peerDependencies)
[![dependencies](http://img.shields.io/david/deepsweet/mustache-loader.svg?style=flat-square)](https://david-dm.org/deepsweet/mustache-loader#info=dependencies)

Compiles [Mustache](https://mustache.github.io/) templates with [Hogan](https://twitter.github.io/hogan.js/) and optionally [html-minifier](https://github.com/kangax/html-minifier).

### Install

```sh
$ npm i -S mustache-loader
```

### Usage

webpack@1.x
```javascript
module: {
    loaders: [ {
        test: /\.html$/,
        loader: 'mustache'
        // loader: 'mustache?minify'
        // loader: 'mustache?{ minify: { removeComments: false } }'
        // loader: 'mustache?noShortcut'
    } ]
}
```
webpack@2.x
```javascript
module: {
    rules: [ {
        test: /\.html$/,
        loader: 'mustache-loader'
        // loader: 'mustache-loader?minify'
        // loader: 'mustache-loader?{ minify: { removeComments: false } }'
        // loader: 'mustache-loader?noShortcut'
    } ]
}
```

```javascript
var template = require('./template.html');
var html = template({ foo: 'bar' });
```

If `noShortcut` is passed, then Hogan compiled template is returned instead, so
you can pass it as partial.

```javascript
var template = require('./template.html');
var template2 = require('./template2.html');
var html = template.render({ foo: 'bar' }, {partial: template2});
```

If `clientSide` is passed in, then Hogan will not pre-compile the template.

If `tiny` is passed in, the source of the template will not be emitted, creating a smaller output.

if `render` is passed in, the data is sent is used to immediately render the template.  Render may be an object or a function which returns an object (in order to allow the data to change over time, e.g. to support hot reloading).

For example, the following will render `index.mustache` with the provided data (`title`), which can immediately be used by HtmlWebpackPlugin.

```javascript
module: {
    rules: [ {
        test: /index\.mustache$/,
        loader: 'mustache-loader',
        options: {
            tiny: true,
            render: {
                title: 'hello world',
            },
        },
    } ]
}
plugins: [
    new HtmlWebpackPlugin({
        template: 'index.mustache',
        inject: 'body',
    }),
]
```

If another loader is chained after Mustache-Loader then the `minify`, `clientSide`, and `tiny` options will be ignored.

Any additional Hogan parameters passed into this loader will be passed through to Hogan.

[Documentation: Using loaders](https://webpack.github.io/docs/using-loaders.html).

### License
[WTFPL](http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-strip.jpg)

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