Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

template20

metaraine3ISC1.0.0

jQuery templating with promise support in 20 lines

jquery, template, templating

readme

template20

npm version

jQuery templating with promise support in 20 lines of code.

Currently CommonJS only (supported by browserify, webpack, etc).

Install

npm install --save template20

Usage

Define a template in your HTML:

<div data-template='person'>
  <h1 data-template-key='name'>
  <a data-template-key='linkUrl' data-template-attr='href'><span data-template-key='linkText'></span></a>
</div>

Hide templates in your CSS:

[data-template] {
  display: none;
}

Clone and populate templates using template20:

```js
var template20 = require('template20')

$('body').append(template20('person', {
  name: 'Bob',
  linkText: 'homepage',
  linkUrl: $.get('/users/bob')
    .then(function(data) { return data.url })
}))

License

ISC © Raine Lourie