New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

express-layout

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-layout

Adds layout support to Express

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
314
-2.79%
Maintainers
1
Weekly downloads
 
Created
Source

express-layout

Adds layout support to Express

Installation

npm install express-layout

Usage

Express-layout is a middleware that overrides the standard res.render() method. Initialize it with:

var express = require('express'),
    layout = require('express-layout'),
    app = express();

app.use(layout());

By default, res.render() will render the view and pass the string of html as a body variable to a file named layout in the views folder. You can alter the layout used by passing an option. For example:

res.render('hello-world', { layout: 'alternative' });

If you pass false, the view will not render within a layout.

You can set a global default layout name and/or directory in which to search for layout files. These can be set by passing an options hash to the middleware on instantiation (layout and layouts are the keys, respectively). Alternatively, you can set them using Express' built-in global settings:

app.set('layouts', './views/layouts');
app.set('layout', 'default');

Finally, an example template in jade might look like this:

doctype 5
html(lang="en")
  head
    title Hello
  body!= body

Keywords

express

FAQs

Package last updated on 18 Nov 2013

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