bigpipe-layout

Supply default layout to Bigpipe pages.

npm install bigpipe-layout
9 downloads in the last month

Layout

Build
Status NPM version

Bigpipe plugin that will provide an easy method to add a general layout to pages. The Bigpipe#Temper instance is used to load your provided layout. The template engine of the file is automatically detected. The page is supplied to the layout as partial by default, changable through options#key.

Features

  • Provide default layout to each page
  • Utilizes Bigpipe#Temper to automatically detect the template engine
  • Fully customizable layout page, options provide full control

Example of layout file using the embedded js template egine

<div><%- partial %></div>

Installation

The layout plugin is released to npm and can be installed using:

npm install bigpipe-layout --save

To use the plugin from Bigpipe, simply add it after Bigpipe is initialized or add it to options#plugins. bigpipe.use will execute the plugin logic. Make sure the plugin name is unique, e.g. layout by default.

// Usage after initialization
var layout = require('bigpipe-layout')
  , BigPipe = require('bigpipe');

//
// Add valid path to base layout.
//
layout.options = { base: '/path/to/base/layout.ejs' };
layout.key = 'custom';

var pipe = new BigPipe(http.createServer(), {
  pages: __dirname + '/pages',
  public: __dirname + '/public'
}).listen(8080).use(layout);
// Usage through createServer options
var layout = require('bigpipe-layout')
  , BigPipe = require('bigpipe');

//
// Add valid path to base layout.
//
layout.options = { base: '/path/to/base/layout.ejs' };

var pipe = BigPipe.createServer(8080, {
  pages: __dirname + '/pages',
  public: __dirname + '/public',
  plugins: [ layout ]
});

License

MIT

npm loves you