node package manager

nailplate

A templating package for node.js

Nailplate is a simple templating system for node.js. It started based on Jinja2, but quickly evolved on its own.

Note: Nailplate is currently in heavy development and is not yet ready for production use. Use at your own risk (for now).

Here is a short list of features:

  • Clear and simple syntax, aimed at formatting instead of application logic.
  • Can be used in a non HTML/XML context.
  • User-extensible (i.e. new tags can easily be added).
  • Supports template includes.
  • Supports template inheritance.

Examples

base.tmpl: Nailplate Example

Nailplate Examples

{{block content}}No Content{{/block}}
Some footer.

index.tmpl {{include base.tmpl}} {{block content}}

I am the index content.

I contain variable foo with value {{var foo}}default{{/var}}, or without default: {{var foo/}}.

{{block innerblock}}

This is a block which can be further overridden in subtemplates. If not, this content is shown as default.

{{/block}}

Partials can be included like this: {{include includeme/}}

{{if somevalue}}

If somevalue evaluates to a a JavaScript true value, this block is rendered.

{{/if}} {{for val in values}}

Values contains {{var val/}}.

{{/for}} {{/block}} {{/include}}