layouts

Wrap templates with layouts. Layouts can be nested and optionally use other layouts.

layouts

Wrap templates with layouts. Layouts can be nested and optionally use other layouts.

Install with npm

npm i layouts --save
var layouts = require('layouts');

Example

layouts('<div>This is content</div>', 'base', {base: {content: 'base above\n{% body %}\nbase below'}});

Results in:

base above
<div>This is content</div>
base below
layouts(string, name, layouts);

Given an object of layouts, and the name of a starting layout:

  1. build a layout stack (from the layouts object) for the given string, then
  2. iterate over the stack, wrapping each layout in the stack around the string
  3. return the string with layouts applied

.layouts

  • str {String}: The content string that should be wrapped with a layout.

  • name {String}: The name of the layout to use.

  • layout{s} {Object}: Object of layouts. name should be a key on this object.

  • options {Object}

    • layoutDelims {Object}: Custom delimiters to use.
    • defaultLayout {Object}: Default layout to use.
  • returns {String}: Returns the original string, wrapped with a layout, or layout stack.

Brian Woodward

Copyright (c) 2014-2015 Brian Woodward
Released under the MIT license


This file was generated by verb on February 13, 2015.