Skip to content

jQuery templating with promise support in 20 lines of code.

License

Notifications You must be signed in to change notification settings

raineorshine/template20

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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

About

jQuery templating with promise support in 20 lines of code.

Resources

License

Stars

Watchers

Forks

Packages

No packages published