<commit_before>adapter-template
================

Adapters to standardise the interfaces on the plethora of available templating engines.

[![wercker status](https://app.wercker.com/status/b56d4ba83550c79c90a82f510dc523df/m/master "wercker status")](https://app.wercker.com/project/bykey/b56d4ba83550c79c90a82f510dc523df)

# Usage

To use the adapter, invoke the package with the name of the template *language* you want to use:

```javascript
var adapter = require('adapter-template');
var jade = adapter('jade');
```

The adapter will now provide access to an appropriate templating engine via a `renderFile` method which takes as parameters a path to a template, an object that can be used by that template, and a callback:

```javascript
jade.renderFile('./test/fixtures/user.jade', { user: 'tobi' }, function (err, html){
  console.log(html);
});
```

To use the adapter in Express, do the following:

```javascript
var express = require('express');
var adapter = require('adapter-template');
var engineName = 'jade';

var app = express();

app.engine(engineName, adapter(engineName).renderFile);
app.set('views', __dirname + '/fixtures');
...
```

Express requires a function that takes a path, locals and a callback, which `renderFile` does.

# Adding Additional Templating Engines

## Adding an Engine That Already Supports Express

The easiest templating libraries to support are those that:

* provide Express support by way of the `express()` or `renderFile()` method;
* have the same module name as the template file extension.

All that is required for these is to add an entry for an engine to the dependencies in `package.json`, and a template with the same file extension to the fixtures collection in the tests directory (see `test/fixtures`). This template will be picked up automatically when running tests, and its presence will cause a test to be run for the corresponding template engine.

# Adding an Express-compatible Engine Named Differently to Its Language

The next most simple templating engine to support are those that:

* provide Express support by way of the `express()` or `renderFile()` method;
* have a different module name to the template file extension.

As described in the previous section, an entry is needed in `package.json` and a template must be added to the fixtures collection in the tests directory in order to trigger tests. But in addition an entry is needed in `lib/setModuleDefaults.js` to indicate what the real module name is. For example, to use the module `hbs` to provide Handlebars support, the following needs to be added to the default settings:

```javascript
handlebars: {
  module: 'hbs'
}
```

Without this entry the generic adapter will try to load a module called `handlebars`.

# Template Languages Supported:

* atpl
* ejs
* handlebars
* jade
* swig
* toffee
* whiskers

# Changelog

## 2014-07-28 (v0.6.0)<commit_msg>Minor layout change in README.<commit_after>adapter-template
================

Adapters to standardise the interfaces on the plethora of available templating engines.

[![wercker status](https://app.wercker.com/status/b56d4ba83550c79c90a82f510dc523df/m/master "wercker status")](https://app.wercker.com/project/bykey/b56d4ba83550c79c90a82f510dc523df)

# Usage

To use the adapter, invoke the package with the name of the template *language* you want to use:

```javascript
var adapter = require('adapter-template');
var jade = adapter('jade');
```

The adapter will now provide access to an appropriate templating engine via a `renderFile` method which takes as parameters a path to a template, an object that can be used by that template, and a callback:

```javascript
jade.renderFile('./test/fixtures/user.jade', { user: 'tobi' }, function (err, html){
  console.log(html);
});
```

To use the adapter in Express, do the following:

```javascript
var express = require('express');
var adapter = require('adapter-template');
var engineName = 'jade';

var app = express();

app.engine(engineName, adapter(engineName).renderFile);
app.set('views', __dirname + '/fixtures');
...
```

Express requires a function that takes a path, locals and a callback, which `renderFile` does.

# Adding Additional Templating Engines

## Adding an Engine That Already Supports Express

The easiest templating libraries to support are those that:

* provide Express support by way of the `express()` or `renderFile()` method;
* have the same module name as the template file extension.

All that is required for these is to add an entry for an engine to the dependencies in `package.json`, and a template with the same file extension to the fixtures collection in the tests directory (see `test/fixtures`). This template will be picked up automatically when running tests, and its presence will cause a test to be run for the corresponding template engine.

## Adding an Express-compatible Engine Named Differently to Its Language

The next most simple templating engine to support are those that:

* provide Express support by way of the `express()` or `renderFile()` method;
* have a different module name to the template file extension.

As described in the previous section, an entry is needed in `package.json` and a template must be added to the fixtures collection in the tests directory in order to trigger tests. But in addition an entry is needed in `lib/setModuleDefaults.js` to indicate what the real module name is. For example, to use the module `hbs` to provide Handlebars support, the following needs to be added to the default settings:

```javascript
handlebars: {
  module: 'hbs'
}
```

Without this entry the generic adapter will try to load a module called `handlebars`.

# Template Languages Supported:

* atpl
* ejs
* handlebars
* jade
* swig
* toffee
* whiskers

# Changelog

## 2014-07-28 (v0.6.0)
{'fraction_non_alphanumeric': 0.08943370165745856, 'fraction_numerical': 0.01761049723756906, 'mean_word_length': 4.87525354969574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1127947', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1553, 'n_words': 749}