2.0.0 • Published 7 years ago

template-stamp v2.0.0

Weekly downloads
6
License
SEE LICENSE IN LI...
Repository
github
Last release
7 years ago

stamp

HTML templates using the <template> tag.

Given the following template:

<template id=t>
  <p><a href-="{{ url }}">{{ foo.bar.baz }} {{ quux }}</a>!</p>
</template>

And the following data:

var data = {
  foo: { bar: { baz: "Hello"}},
  quux: "World",
  url: "http://example.com",
};

Then the following code will expand the template against the data and append it to the body:

var ctx = new Stamp.Context();
var expanded = Stamp.expand(ctx.import('t'), data);
Stamp.appendChildren(document.body, expanded);

The expansion will look like:

<p><a href="http://example.com">Hello World</a>!</p>

See the documentation for more info.