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

cbourgois/HandlebarsLoader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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