artist

0.1.5 • Public • Published

Artist

Build Status

Artist is a template engine for node.js built on fest.

Features:

  • Caches compiled templates
  • Synchronous and asynchronous API
  • Express-compatible
  • Handles fest's runtime errors
  • Connect's middleware proxy

Installation

npm install artist

API

View source for documentation.

Usage

With express:

app.engine('xml', require('artist').render());

With express (production environment):

app.engine('xml', require('artist').render({
    cache: true,
    debug: false
}));

Synchronous version:

var render = require('artist').renderSync();
// ...
var html = render('index.xml', {foo: 'bar'});

index.xml

<?xml version="1.0"?>
<fest:template xmlns:fest="http://fest.mail.ru" context_name="json">
    <fest:value>json.foo</fest:value>
</fest:template>

Proxy

Proxy is a connect middleware. It handles requests to the templates, compiles them and wraps results into AMD module, JSONP or any other format.

AMD:

app.use(require('artist').proxy({
    format: 'amd', // 'amd', 'jsonp' or any string with #ID# and #FN# placeholders
    route: '/scripts/templates', // middleware mounting point
    templates: app.get('views') // path to the view directory
}));

GET /scripts/templates/layout.js

define(function(){return function(__fest_context){
    ...
}});

JSONP:

app.use(require('artist').proxy({
    format: 'jsonp',
    route: '/scripts/templates',
    templates: app.get('views')
}));

GET /scripts/templates/layout.js?jsonp=handleTemplate

handleTemplate(function(__fest_context){
    ...
});

Readme

Keywords

none

Package Sidebar

Install

npm i artist

Weekly Downloads

12

Version

0.1.5

License

none

Last publish

Collaborators

  • eprev