Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Templating middleware for embedded javascript templates.
JavaScript
Branch: master
Failed to load latest commit information.
example obedient
test use express for examples
.gitignore init
.travis.yml init
Makefile init
index.js allow no data to be passed to res.render
package.json allow no data to be passed to res.render
readme.md use express for examples

readme.md

Masonry - Templating middleware for embedded javascript templates.

Install: npm install masonry


masonry(directory):

Pass a directory of templates. Masonry will read all of the template files into memory.

res.render('template.ejs', data)

Method added by the middleware. Renders a template. If a third parameter (callback) is provided the data will be returned rather than sent to the browser. The first param will be an error object, the second will be the rendered html.

var app = require('express').createServer()
var masonry = require('masonry')

app.use(masonry(__dirname + '/templates'))

app.get('/:user', function(req, res) {
  res.render('index.ejs', {user: req.params.user})
})

app.get('/return/:user', function(req, res) {
  res.render('index.ejs', {user: req.params.user}, function(err, html){
    if(err) throw new Error(err)
    res.end(html)
  })
})

app.listen(3000)

Deps:

EJS documentation: https://github.com/visionmedia/ejs


Examples:

View the examples


Tests

npm test

Build Status

Something went wrong with that request. Please try again.