0.0.5 • Public • Published


Stencil Build Status Coverage Status

Asynchronous HTML5 templating for Node.js and the browser. Photo by mufflevski.

Thoughts on Stencil? Join the Discussion.



<s:include xmlns:s="stencil">
  <s:tag name="document">
      <title><s:value select="attr.title"/></title>
      <s:block name="head"/>
      <h1><s:value select="attr.title"/></h1>
      <s:block name="body"/>

Pages laid out.

<o:document xmlns:s="stencil" xmlns:o="inc:layout.stencil" title="Hello, World!">
  <o:head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></o:head>
  <o:body><p>Hello, World!</p></o:body>

The same templates run on the browser and in Node.js, so you can use the same logic you use to serve a generate page to refresh that page.

Stencil on the Server

On the server, we create a template and serialize it to HTML5. You can also serialize to older HTML flavors for older browsers.

Stencil on the Browser

On the browser, when we generate Stencil XML, we simply import it into the existing DOM using Document.adoptNode.


  • It's not a query tool. It's a templating tool.


  • Functions must have no side-effects; i.e. do not use your template functions to create a hit counter.
  • It's not hard to write template functions that do not have side effects. The sort of functions that might have side effects are not likely to appear in the logic that supports emitting markup.


Revisiting the ideas explored in a Java based Stencil.

Stencil is asynchronous HTML5 templating for Node.js and the browser. It based on some ideas from yesteryear and some ideas from tomorrow.

This project evolved from work with Streamline and CoffeeScript. That work has been moved to a project named Pastiche.


Especially when dealing with a library that has a goal of being small, you're limited as to how much scaffolding you can offer developers. My approach for Stencil is to define three roles, application developer, web developer, and web designer, and say the first two roles labor to create a childlike sense of wonder in the latter role.

An application developer creates APIs that the web developer can query. The web developer wraps those APIs in tag libraries, so that the web designer can focus on semantic layout.

Change log

Changes for each release.

Version 0.0.5

Mon Apr 22 19:07:43 UTC 2013

  • Fix non-directive with attribute child directives. #108.

Version 0.0.4

Tue Apr 16 14:15:19 UTC 2013

  • Add request and response to Stencil service. #106.

Package Sidebar


npm i stencil

Weekly Downloads






Last publish


  • bigeasy