Skip to content
This repository has been archived by the owner on Feb 10, 2020. It is now read-only.

Latest commit

 

History

History
103 lines (78 loc) · 1.75 KB

README.md

File metadata and controls

103 lines (78 loc) · 1.75 KB

HandlebarsLoader (v 0.2.0)

This script help to load Handlebars templates and partials easily.

How to install it via Package Managers

  • Bower: handlebars-loader

How to use it

Initialisation

var loader = new HandlebarsLoader();
loader.load([ 
		'template1', 
		'template2',
		'template3'
	], 
	[         
		'partial1'
	],  
	function() {   
		// templates are available...
	}
);

To use a template

loader.getTemplate('template1')();

To use easily all templates

var templateContainer = loader.getAllTemplates();
templateContainer.template1();
templateContainer.template2({foo: 'bar'});

Options

By default, the loader will load template1 in tpl/template1.html and partial1 in tpl/partials/partial1.html.

Name Definition Default value
baseUrl Define templates folder tpl/
partialUrl Define partials folder tpl/partials/
extension Define template & partial extension html

Define options at initialisation:

var loader = new HandlebarsLoader({
  baseUrl: 'templates/',
  partialUrl: 'partials/',
  extension: 'hb'
});

Now, this loader will load template1 in templates/template1.hb and partial1 in partials/partial1.hb.

How to build it

Simply execute

make