easy-handlebars-js

1.0.2 • Public • Published

easy-handlebars-js

npm version

Easy to memorize API to compile handlebars templates on client-side.

Usage

Add your template(s) using script tag:

<script id="my-template" type="text/x-handlebars-template">
  <h1>{{title}}</h1>
</script> 

Then, on JavaScript:

const easyHandlebars = require('easy-handlebars');
 
easyHandlebars('my-template').compile({
  title: 'Hi there!'
});

Why is easyHandlebars simpler?

Check the following comparison:

easyHandlebars API

let compiled = easyHandlebars('my-template').compile({
  title: 'Hi there!'
});

The native Handlebars way

let templateEl = document.querySelector('#my-template');
let templateHtml = templateEl.innerHTML;
let template = Handlebars.compile(templateHtml);
 
let compiled = template({
  title: 'Hi there!'
});

Dependents (0)

Package Sidebar

Install

npm i easy-handlebars-js

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ramonvictor