# layouts [](https://www.npmjs.com/package/layouts) [](https://travis-ci.org/doowb/layouts)
> Wraps templates with layouts. Layouts can use other layouts and be nested to any depth. This can be used 100% standalone to wrap any kind of file with banners, headers or footer content. Use for markdown, HTML, handlebars views, lo-dash templates, etc. Layouts can also be vinyl files.
- [Install](#install)
- [Usage](#usage)
- [Examples](#examples)
- [Customization](#customization)
- [API](#api)
- [History](#history)
- [Related projects](#related-projects)
- [Running tests](#running-tests)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm i layouts --save
```
## Usage
```js
var renderLayouts = require('layouts');
```
## Examples
**Basic example**
In this example, two layouts are used:
* the first layout, `one`, will wrap the string
* the second layout, `two`, will wrap the first layout
```js
var layouts = {
one: {content: 'one before\n{% body %}\none after', layout: 'two'},
two: {content: 'two before\n{% body %}\ntwo after'},
};
// `one` is the name of the first layout to use on the provided string
renderLayouts('
Wrap me with a layout!!!
', 'one', layouts);
```
Results in:
```html
two before
one before
Wrap me with a layout!!!
one after
two after
```
**HTML**
This example shows how to use nested HTML layouts to wrap content:
```js
var layouts = {};
layouts.base = {
path: 'base.tmpl',
content: [
'',
'',
' ',
' ',
' Home',
' ',
' ',
' {% body %}',
' ',
'',
].join('\n')
};
// this `nav` layout will be wrapped with the `base` layout
layouts.nav = {
path: 'nav.tmpl',
layout: 'base',
content: ''
};
// this string will be wrapped with the `nav` layout
var str = [
'