Skip to content

Compiles pug templates into an object representation based on the pug template directory structure

License

Notifications You must be signed in to change notification settings

dambrisco/pug-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pug-tree
Credit: flickr/dapuglet

pug-tree

NPM version Dependency status CI status

pug-tree is a tiny library design to build nested objects of templating functions from a given directory of pug template files.

Installation and Usage

  • npm install --save pug-tree
  • require('pug-tree')(directory, defaults)
    • directory should be the top level of your templates folder, usually something like path.join(__dirname, 'templates')
    • defaults is properties object that is pre-bound to template - this is a good place to include information that doesn't usually change like title
    • See test/test.js for usage example

Given a folder structure:

<project-name>
↳ templates
  ↳ index.pug
  ↳ nested
    ↳ page.pug

You will be able to do the following:

var templates = require('pug-tree')(path.join(__dirname, 'templates'), { title: title })
var indexHtml = templates.index({ body: indexBody })
var nestedPageHtml = templates.nested.page({ body: nestedPageBody })

Where title and body are both available to each of the templates.

About

Compiles pug templates into an object representation based on the pug template directory structure

Resources

License

Stars

Watchers

Forks

Packages

No packages published