choo-layout

1.0.0 • Public • Published

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>
        <div class="row">here comes the train... :train:</div>
        <div>
          ${0}
        </div>
      </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) => {
  app.router([
    ['/', 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...)

Readme

Keywords

none

Package Sidebar

Install

npm i choo-layout

Weekly Downloads

2

Version

1.0.0

License

ISC

Last publish

Collaborators

  • madeline