Skip to content

osoner/HandlebarLoader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

HandlebarLoader

This script help to load Handlebar templates and partials easily.

How to use

Initialisation

var loader = new HandlebarLoader();
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 HandlebarLoader( {
    baseUrl: 'templates/',
    partialUrl: 'partials/',
    extension: 'hb'
} );

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

About

Simple js script to load handlebar templates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published