arc-templates

0.5.3 • Public • Published

arc-templates

Fully powered ES6 JavaScript template engine with halfway-decent syntax.

GitHub version Build Status (lint + tests)

Dependency Status devDependency Status

There are two "builds" available: a Node.js 4+ version with minimal Babel transpiling, and an ES5 version with full Babel transpiling. The unit tests are run on both new and older Node versions.

Simple example

Templates can use expressions:

Hello, ${ name }

with a data object of { name: 'world' } will result in:

Hello, world

Loops

JavaScript blocks with nested document blocks allow a natural expression of loops:

<% for (let item of items) { <:<div>${item}</div>:> } %>

Layouts

Templates can define layouts for a "template of the template":

<! layout.html !><div>body</div>

If layout.html contains:

<html><head></head><body><**></body></html>

Then the final result is:

<html><head></head><body><div>body</div></body></html>

Templates can also define multiple named blocks for use by the layout template; for example, separate sections for the head and body in an HTML document.

Partials

Templates can also include other templates in their output:

before <( include.html )> after

If include.html contains:

middle

Then the final result is:

before middle after

Readme

Keywords

Package Sidebar

Install

npm i arc-templates

Weekly Downloads

23

Version

0.5.3

License

MIT

Last publish

Collaborators

  • stephencleary