FAQ Database Discussion Community

NodeJs with Express and Handlebars - handlebars.engine is undefined

I am following the tutorials in O'Reilly's "Web Development with Node & Express" by Ethan Brown. They use handlebars as the view engine. Here is my code: var express = require ('express'), handlebars = require('express3-handlebars'), app = express(); handlebars.create({ defaultLayout: 'main' }); app.engine('handlebars', handlebars.engine); The problem I am having is...

View engine that supports both ajax and direct calls

I'm looking for a way to serve a template in Node.js (Express) both "normally" rendered as HTML and rendered as JSON, if it was requested with ajax. Let's say I have a template like this in swig: {% extends 'layout.html' %} {% block title %}Default Page{% endblock %} {% block...