Skip to content

Instantly share code, notes, and snippets.

View andrewdanks's full-sized avatar

Andrew Danks andrewdanks

View GitHub Profile
@andrewdanks
andrewdanks / utils.js
Created October 2, 2012 03:47
A simple utility function for rendering a sequence of templates in express for node.
/*
A simple utility function for rendering a sequence of templates in express for node.
Usage:
var utils = require('./utils');
utils.renderTemplates(res, ['header', 'about', 'footer'], {title: 'About'});
*/
module.exports.renderTemplates = function(res, templates, params, callback, error_callback) {
// By default we just send the html in the response
@jed
jed / rendering_templates_obsolete.md
Created October 19, 2012 05:07
Rendering templates obsolete

(tl;dr DOM builders like [domo][domo] trump HTML templates on the client.)

Like all web developers, I've used a lot of template engines. Like most, I've also written a few of them, some of which even [fit in a tweet][140].

The first open-source code I ever wrote was also one of the the first template engines for node.js, [a port][node-tmpl] of the mother of all JavaScript template engines, [John Resig][jresig]'s [micro-templates][tmpl]. Of course, these days you can't swing a dead cat without hitting a template engine; one in eight packages on npm ([2,220][npm templates] of 16,226 as of 10/19) involve templates.

John's implementation has since evolved and [lives on in Underscore.js][underscore], which means it's the default choice for templating in Backbone.js. And for a while, it's all I would ever use when building a client-side app.

But I can't really see the value in client-side HTML templates anymore.