Skip to content

jcgregorio/stamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.