Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

node.js/express port of spree/deface. Allows overriding of HTML without partials.

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time


node-deface is a port of to node.js and express.

You can now find us in npm!

It allows developers to customize node.js HTML views without requiring partials or editing the underlying view.

You can use any template library. node-deface works by extending res.render to look up override scripts and apply them after template rendering.

Overrides use css selectors to find what to replace and use path to determine which view to apply to.

The text inside the override can be specified by whichever template library is passed to deface.override(app,template_library,folder) .

The interface for the template_libray object is:

engine.compile(body) which returns a function(options)


These need to be done before considering node-deface usable:

  • Add benchmarks to show differences in speed.
  • Add documentation of speed differences.
  • Add support for multiline strings (coffeescript can do this. We can make our overrides coffeescript and the rest plain node.js)
  • Add gruntfile build script.
    • Add mocha tests.
    • Add to travis-ci.
  • (COMPLETED) Replacement text in Deface.override isn't processed as template yet, only string (IMPORTANT for making this usable)
  • (COMPLETED) If you don't have an override for a specific view, the processing fails. (IMPORTANT for making this usable)
  • (COMPLETED) Overrides are loaded every request. They should only be loaded at startup. (IMPORTANT for speed)

These are some other TODOs which are pluses but not required:

  • Port to coffeescript?
  • Add JSON or yaml support for deface override files.
  • Add precompilation of templates + overrides where supported.
  • Create gh-pages.



module.exports = function(Deface) {
    return Deface.override({
        path: "index", //view name without the file extension.
        replace: "[data-hook=...]", // any CSS selector.
        text: "<p>Title: {{title}}</p>" // any HTML text.


    <p>Welcome to deface. Title: {{title}}</p>
    <div data-hook="...">
        <p>This content will be overriden.</p>



var template_lib = require('any-template-library')
var deface = require('deface')

//attach deface middleware using folder name 'overrides'
Something went wrong with that request. Please try again.