hyper-template
transform hyper+json data with a template
Last updated 6 years ago by camshaft .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install hyper-template 
SYNC missed versions from official npm registry.

hyper-template

transform hyper+json data with a template

Installation

$ npm install hyper-template

Usage

var create = require('hyper-template');

var template = create({
  user: {
    name: 'user.full-name',
    gender: '@', // aliases to user.gender
    address: 'concat(user.address.street, "\n", user.address.city, ", ", user.address.state, " ", user.address.zip)'
  }
});

template.def('concat', function() {
  return Array.prototype.join.call(arguments, '');
});

var scope = {
  user: {
    href: 'https://api.example.com/user/123'
  }
};

template(scope, function(err, res) {
  console.log(res); // {user: {name: 'Mike Smith', gender: 'male', address: '123 Fake St.\nNowhere, KS 12345'}}
});

Current Tags

  • 0.1.3                                ...           latest (6 years ago)

4 Versions

  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (2)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |