Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

layouts

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

layouts

Wrap templates with layouts. Layouts can use/refer to other layouts, allowing them to be nested.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

layouts NPM version

Wrap templates with layouts. Layouts can use/refer to other layouts, allowing them to be nested.

Install

npm
npm i layouts --save

Usage

var layouts = require('layouts');

API

Layouts

Create a new instance of Layouts, optionally passing the default cache and options to use.

Example:

var Layouts = require('layouts');
var layout = new Layouts();
  • cache {Object}: A template cache. See Layouts#set for object details.
  • options {Object}: Options to use.
  • options.delims {Array}: Template delimiters to use formatted as an array (['{{', '}}'])
  • options.tag {String}: The tag name to use. Default is body (e.g. {{ body }})

.set

Store a template on the cache by its name, the layout to use, and the template's `content.

Example:

layout.set('a', 'b', '<h1>Foo</h1>\n{{body}}\n');
  • name {String|Object}: If name is a string, layout and content are required.
  • data {String|Object}: Pass a string defining the name of layout to use for the given template, or pass an object with a layout property.
  • content {String}: The template "content", this will not be compiled or rendered.

.get

Get a cached template by name.

Example:

layout.get('a');
//=> { layout: 'b', content: '<h1>Foo</h1>\n{{body}}\n' }
  • name {String}
  • return {Object} The template object to return.

.wrap

Flatten nested layouts.

Example:

var page = layout.wrap('base');
var tmpl = _.template(page, context);
  • name {String}: The layout to start with.
  • return {String} Resulting flattened layout.

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on July 28, 2014.

Keywords

FAQs

Package last updated on 28 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc