node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »


choo-layout is a way to wrap templates with other templates (yo dawg?)

The inspiration came from iron-router because I wanted to be able to have certain pages be contained within another without having to maintain each instance of the 'wrapper' template.

How to use it:

Create a layout:

const layout = require('choo-layout')
module.exports = layout`
        <div class="row">here comes the train... :train:</div>

A layout can have multiple 'yields' (where the given page will go). Unfortunately there is no 'named' templates yet but it shouldn't be hard to add. (;))

Use a layout:

const layout = require('../views/layout')
const dashboard = require('../views/dashboard')
module.exports.boot = (app) => {
    ['/', layout(dashboard)]

Boom! You have a layout. If you wanted multiple templates in your layout, you would pass like you would pass an additional parameter to a function (because app.router doesn't need more arrays...)