Skip to content

sitepoint-editors/handlebars-precompilation-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

handlebars-precompilation-demo

A demo to show how handlebars precompilation works

  1. keep all the template files with .handlebars extension inside the templates folder.
  2. In the root folder run handlebars templates/ -f templatesCompiled.js
  3. You will get a compiled templatesCompiled.js in the root directory.
  4. Insert the runtime handlebars and the compiled js file
<script src="handlebars.runtime.js"></script>
<script src="path/to/templatesCompiled.js"></script>
  1. Access the template of demo.handlebars by using
var context = {
	"name":"Ritesh Kumar",
	"occupation" : "Developer"
}

var templateScript = Handlebars.templates.demo(context);

$(body).append(templateScript);
  1. Run index.html on the browser to see the resultant html.

That's it.

About

A demo to show how handlebars precompilation works

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.6%
  • HTML 21.5%
  • Handlebars 6.9%