# grunt-twig-renderer

> Renders twig templates to html files

Latest version **1.0.1** (published 2016-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install grunt-twig-renderer
pnpm add grunt-twig-renderer
yarn add grunt-twig-renderer
bun add grunt-twig-renderer
```

## 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.0.1 |
| Published | 2016-02-20 |
| First published | 2016-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dmitriy Poluektov |
| Maintainers | ashot |
| Keywords | gruntplugin, twig, render, templates |

## Links

- npm: https://www.npmjs.com/package/grunt-twig-renderer
- Repository: https://github.com/Ashot-KR/grunt-twig-renderer
- Homepage: https://github.com/Ashot-KR/grunt-twig-renderer#readme
- Issues: https://github.com/Ashot-KR/grunt-twig-renderer/issues
- npm.io page: https://npm.io/package/grunt-twig-renderer

## Dependencies (3)

- [twig](https://npm.io/package/twig.md) ^0.8.8
- [chalk](https://npm.io/package/chalk.md) ^1.1.1
- [js-beautify](https://npm.io/package/js-beautify.md) ^1.6.2

## Recent versions

- 1.0.1 (latest) — 2016-02-20

## README

# grunt-twig-renderer

> Grunt plugin for rendering twig templates to html files

## 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-twig-renderer --save-dev
```

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

```js
grunt.loadNpmTasks('grunt-twig-renderer');
```

## The "twigRenderer" task

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

```js
grunt.initConfig({
  twigRenderer: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})
```

### Options

#### options.data
Type: `String|Function`

Path to json or yaml file contains data for templates.  
If a function is provided, it should return a path to data file.
```js
{
  data: function(tpl) {
    // tpl argument is a path to template
    if (tpl == 'special.twig') {
      return 'special-data.json';
    } else {
      return 'data.json';
    }
  }
}
```

#### options.beautify
Type: `Object|Boolean`

Configuration for beautifier. See [js-beautify](https://github.com/beautify-web/js-beautify) for available options.
`false` value will disable beautifier.

### Usage Examples
```js
grunt.initConfig({
  twigRenderer: {
    options: {
      data: 'data.json',
      beautify: {
        "indent_size": 2,
        "indent_char": " ",
        "indent_with_tabs": false
      }
    },
    files: {
      'dist/index.html': ['views/index.twig']
    }
  },
})
```
  
If multiple sources for one destinations is provided, different files with fixed destination path will be created.  
In following example two files will be created: `dist/dest_index.html` and `dist/dest_second.html`
```js
grunt.initConfig({
  twigRenderer: {
    options: {
      data: 'data.json'
    },
    files: {
      'dist/dest.html': ['views/index.twig', 'views/second.twig']
    }
  },
})
```

## License
Copyright (c) 2016 Dmitriy Poluektov. Licensed under the MIT license.

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