# grunt-template-js

> Compiles HTML templates to JavaScript variables, jsonp and CMD.

Latest version **0.0.2** (published 2014-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install grunt-template-js
pnpm add grunt-template-js
yarn add grunt-template-js
bun add grunt-template-js
```

## 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.0.2 |
| Published | 2014-07-15 |
| First published | 2014-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | nqliujiangtao@gmail.com |
| Maintainers | mycoin |
| Keywords | html2js, gruntplugin, htmlCMD |

## Links

- npm: https://www.npmjs.com/package/grunt-template-js
- Repository: https://github.com/mycoin/grunt-template-js
- Issues: https://github.com/mycoin/grunt-template-js/issues
- npm.io page: https://npm.io/package/grunt-template-js

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^0.4.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2014-07-15
- 0.0.1 — 2014-07-14
- 0.0.0 — 2014-07-14

## README

# grunt-template-js

> Compiles HTML templates to JavaScript variables, jsonp and CMD.



## Getting Started
This plugin requires Grunt `~0.4.0`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-template-js --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-template-js');
```

*This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4).*



## `template` task
_Run this task with the `grunt template` command._

Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.

### Options

#### mode
Type: `string`  
Default: `default`

available values are `compress`, `format` and `default`

#### wrap
Type: `Boolean`  
Default: false

Will transmit outputs to `CMD`.

### Usage Examples

There are three formats you can use to run this task.

#### Compiles HTML templates to JavaScript

```js
'template': {
    options: {
        mode: 'format',
        wrap: true
    },

    'build': {
        files: [{
            expand: true,
            cwd: 'src/html',
            src: '**/*.html',
            dest: 'src/html'
        }]
    }
}
```

#### for e.g.
```html
<html>
<head>
    <title>grunt-template-js</title>
</head>
<body>
testing...
</body>
</html>
```
Will compiled to:
```
define(function () {
    return ''
    + '<html>\n'
    + '<head>\n'
    + '    <title>grunt-template-js</title>\n'
    + '</head>\n'
    + '<body>\n'
    + 'testing...\n'
    + '</body>\n'
    + '</html>';
});

```
---

Task submitted by [mycoin](https://github.com/mycoin/)

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