# grunt-add-view

> Input html files and output a js file that exports all of the html as an object in the form {filename:html text}. It is intended to be used as a view object in single page web apps.

Latest version **0.1.0** (published 2015-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install grunt-add-view
pnpm add grunt-add-view
yarn add grunt-add-view
bun add grunt-add-view
```

## 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.1.0 |
| Published | 2015-05-27 |
| First published | 2015-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.12.3 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dale Corns |
| Maintainers | drcorns |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-add-view
- Repository: https://github.com/dcorns/grunt-add-view
- Issues: https://github.com/dcorns/grunt-add-view/issues
- npm.io page: https://npm.io/package/grunt-add-view

## Recent versions

- 0.1.0 (latest) — 2015-05-27
- 0.0.3 — 2015-05-22
- 0.0.2 — 2015-05-22
- 0.0.1 — 2015-05-22

## README

# grunt-add-view

> Input html files and out put a js file that exports all the html as a object of the for {filename:html text}. It is intended to be used as a view object in single page web apps.

## Getting Started
This plugin requires Grunt.

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-add-view --save-dev
```

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

```js
grunt.loadNpmTasks('grunt-add-view');
```

## The "add_view" task

### Overview
In your project's Gruntfile, add a section named `add_view` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  add_view: {
    your_target: {
      // Target-specific file lists go here.
    },
  },
})
```
### Usage Examples

#### Default Options
In this example, the files src/login.htm and src/register.html are compiled into a view object that wrapped in a common js export and stored in dest/view.js. So if the `login.html` file has the content `<label>Hello World</label>` and the `register.html` file had the content `<label for="name">NAME</label><input id="name">`, the generated result contained in `view.js` would be:
 
```view.js
'use strict';
module.exports = {"login":"<label>Hello World</label>", "register":"<label for=\"name\">NAME</label><input id=\"name\">"};
```

```js
grunt.initConfig({
  add_view: {
    files: {
      'dest/view.js': ['src/login.html', 'src/register.html'],
    },
  },
})
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
_(Nothing yet)_

## License
Copyright (c) 2015 Dale Corns. Licensed under the MIT license.

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