Skip to content

stevenvachon/handlebars-virtual-dom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

handlebars-virtual-dom

Compile Handlebars templates to virtual-dom.

Compile this:

<div>
	value1
	{{variable1}}
	{{#if variable2}}<span>value2</span>{{else}}nothing{{/if}}
	<span data-attr="{{#if variable3}}value3{{/if}} value4">value5</span>
</div>

into this:

h("div", [
	"value1",
	context.variable1,
	context.variable2 ? h("span", [
		"value2"
	]) : "nothing",
	h("span", {"data-attr":(context.variable3 ? "value3" : "") + " value4"}, [
		"value5"
	])
);

Usage

Server/Browserify

var handlebarsVirtualDom = require("handlebars-virtual-dom");
var result = new handlebarsVirtualDom(options).compile("<h1>{{title}}</h1>");

AMD/etc

Accessible via define() or window.handlebarsVirtualDom.

Options

See handlebars-html-parser.

Releases

No releases published

Packages

No packages published