71104/jquery-handlebars — pull request #10 by himdel (2014-01-15 00:11:53+00:00)
Title: Added sync option to always render templates synchronously

Added sync option - when true, $.fn.render calls that can't find the template without ajax throw an exception

+ option sync - false by default
when true, no ajax calls are performed

+ $.handlebars( 'add', templateName, templateString )
to add a template to cache

+ $.handlebars( 'has', templateName ) -> bool
returns whether the template is already cached

because if ! has tpl { add tpl; render } is nicer than catching

+ $.handlebars( 'cache' ) -> the cache object

Templates are no longer cached by URL, only by template name.
(Because locally added templates have no url and inventing a fake one would complicate searching if both ways are used.)

The rationale is to be reasonably compatible with jquery.mustache.js, because while converting ```$.fn.mustache( tpl, data, { method: html })``` to ```$.fn.render( tpl, data )``` is easy, lots of code written for mustache expects the template to be rendered synchronously, and without ```sync: true```, ```$('#foo').render('tpl', {}); $('#foo .something').whatever();``` doesn't really work (except when it does).