beardo

A mustache template utility for Node.js servers/ projects.

Usage no npm install needed!

<script type="module">
  import beardo from 'https://cdn.skypack.dev/beardo';
</script>

README

beardo

Provides an easy way to use layout aware mustache templates in your node.js projects. Add mustache files to a templates directory and use beardo's methods to simply asynchronously read and render them as appropriate for your setup.

If you are using one of the http handlers (beardo.middleware, beardo.handler) ETags get automatically added and 304 responses occur based on the if-none-match request header.

beardo.handler(res, req, [options])

Adds a Templar style response handler.

var beardo = require('beardo')
  , beardopts = { directory: path.join(__dirname, './templates')
    , stamp: 'stamp-' + process.pid
    }

http.createServer(function(req, res) {
  res.template = beardo.handler(req, res, beardopts)

  // Meanwhile
  res.template('heyo', { headers: headers, layout: 'html' })
})

Options

  • directory: The directory that holds the mustache files
  • stamp: Gets added to the response header as x-beardo-stamp to aid in debugging