Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stevenvachon/handlebars-virtual-dom

Compile Handlebars templates to virtual-dom.
https://github.com/stevenvachon/handlebars-virtual-dom

handlebars handlebars-html-parser nodejs vdom virtual-dom

Last synced: 21 days ago
JSON representation

Compile Handlebars templates to virtual-dom.

Awesome Lists containing this project

README

        

# handlebars-virtual-dom
> Compile Handlebars templates to [virtual-dom](https://github.com/Matt-Esch/virtual-dom/).

Compile this:
```handlebars


value1
{{variable1}}
{{#if variable2}}value2{{else}}nothing{{/if}}
value5

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

## Usage
### Server/Browserify
```js
var handlebarsVirtualDom = require("handlebars-virtual-dom");
var result = new handlebarsVirtualDom(options).compile("

{{title}}

");
```
### AMD/etc
Accessible via `define()` or `window.handlebarsVirtualDom`.

## Options
See [handlebars-html-parser](https://github.com/stevenvachon/handlebars-html-parser).