npm package: @slietar/templum
Description: A template engine manager
Latest version: 0.2.0

# templum

```figlet

                  ___           ___           ___                       ___           ___
      ___        /  /\         /__/\         /  /\                     /__/\         /__/\
     /  /\      /  /:/_       |  |::\       /  /::\                    \  \:\       |  |::\
    /  /:/     /  /:/ /\      |  |:|:\     /  /:/\:\  ___     ___       \  \:\      |  |:|:\  
   /  /:/     /  /:/ /:/_   __|__|:|\:\   /  /:/~/:/ /__/\   /  /\  ___  \  \:\   __|__|:|\:\
  /  /::\    /__/:/ /:/ /\ /__/::::| \:\ /__/:/ /:/  \  \:\ /  /:/ /__/\  \__\:\ /__/::::| \:\
 /__/:/\:\   \  \:\/:/ /:/ \  \:\~~\__\/ \  \:\/:/    \  \:\  /:/  \  \:\ /  /:/ \  \:\~~\__\/
 \__\/  \:\   \  \::/ /:/   \  \:\        \  \::/      \  \:\/:/    \  \:\  /:/   \  \:\
      \  \:\   \  \:\/:/     \  \:\        \  \:\       \  \::/      \  \:\/:/     \  \:\
       \__\/    \  \::/       \  \:\        \  \:\       \__\/        \  \::/       \  \:\
                 \__\/         \__\/         \__\/                     \__\/         \__\/

```


## Install

```sh
$ npm install @slietar/templum --save
```


## Getting started

```js
var templum = require('@slietar/templum');

templum.mustache.static('lorem {{foo}}', { locals: { foo: 'ipsum' } })
  .then((data) => {
    console.log(data.toString());
  });

// Outputs `lorem ipsum`
```

Using streams:

```js
var templum = require('@slietar/templum');

getReadableStream().pipe(templum.mustache({ locals: { ... } })).pipe(getWritableStream());

// for example:

process.stdin.pipe(templum.mustache()).pipe(process.stdout);
```


## Supported template engines

See `engines.md` for more info.

* dot (planned)
* ejs (planned)
* haml (planned)
* handlebars
* html
* jade
* mustache
* nunjucks
* text
* swig
* underscore


## Options

```js
{
  cache: false,             /* boolean */
  debug: false,             /* boolean */
  filename: null,           /* string */
  locals: {},               /* object */
  style: Style.Default,     /* enum: default, compact, compressed, expanded */
  [custom options]
}
```


## Usage with TypeScript

```sh
$ npm install @slietar/templum --save
$ tsd link
$ tsd install node --save
$ tsc
```


## Writing a template engine

```js
var templum = require('@slietar/templum');

module.exports = templum.engine((input, output) => {
  // input and output are both `through2` streams

  input.on('data', (chunk) => {
    output.write(...);
  });

  input.on('end', () => {
    // don't forget this
    output.end();
  });

  // OR

  input.pipe(...).pipe(output);

  // OR

  // input.concat() and output.throw() are two special methods
  input.concat()
    .then((data) => {
      output.end(...);
    })
    .catch(output.throw);
});
```


## Development

```
$ npm test
$ npm run coverage
```


## Change log

### 0.2.0

* add `handlebars`, `nunjucks`, `swig` and `underscore` template engines
* `findFromExtension` allows a `.` at the beginning
* move `jade` and `mustache` to peer dependencies
* move `lib/a.js` to `a.js` and add `templum.a`
* remove `Q`
* remove `templum.default`
* use streams (`concat-stream`, `duplexer2`, `through2`)

### 0.1.1

* fix TS definition bug

### 0.1.0

* initial version