node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »



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

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)
  • (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)



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>


app.js: var template_lib = require('any-template-library') var deface = require('deface')

//attach deface middleware using folder name 'overrides'