build templates with ordinary html for node and browsers
npm install html-templatebuild templates with ordinary html for node and browsers
Write plain html and use css selectors to modify the html.

Put template= attributes on the elements you want to turn into templates.
Here we'll make a template called `` In node we can do: ` var html = template(); skills.write({ to produce: ` In the browser, do: ` skills.write({ and new elements will be generated dynamically. ` Create a new html template stream html Load a template t Optionally: * opts.include Write row ` Create a new html Load a template t Write a hyperglue-style object mapping Create a hyperglue-style object mapping Create an html With npm do: ` MIT"skill" on a : html`
list of skills
skill name
skill level
in node
js
var template = require('html-template');
var fs = require('fs');
var skills = html.template('skill');
fs.createReadStream(__dirname + '/skills.html')
.pipe(html)
.pipe(process.stdout)
;
'[key=name]': 'macaroni pictures',
'[key=level]': '40%'
});
skills.write({
'[key=name]': 'quilting',
'[key=level]': '5000%'
});
skills.write({
'[key=name]': 'blinky lights',
'[key=level]': '50%'
});
skills.end();
` html`
list of skills
skill name
skill level
macaroni pictures
40%
quilting
5000%
blinky lights
50%
in browsers
js
var html = require('html-template')();
var skills = html.template('skill');
'[key=name]': 'tap dancing',
'[key=level]': '15%'
});
skills.write({
'[key=name]': 'baton twirling',
'[key=level]': '95%'
});
`node methods
`
var template = require('html-template')var html = template()
that takes html input with template
attributes and produces html output with expanded template data.var t = html.template(name, opts)
by its template name in the html. - when false, do not include the original template in thestyle="display:none"
html output. Otherwise include the original template with so the template can be loaded in the browser to create
additional output.t.write(row)
, an object mapping css selector keys to
hyperglue-style values,
to the output stream. browser methods
`
var template = require('html-template')
var streamTemplate = require('html-template/stream')var html = template()
instance.var t = html.template(name)
by its template name in the html.t.write(row)
css selectors to attributes and content to the page.var elem = t.create(row)
without inserting the element elem to the DOM.var html = streamTemplate()
that will create real stream template (t)s.install
``
npm install html-templatelicense