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).
Added sync option - when true, $.fn.render calls that can't find the template without ajax throw an exception
$.handlebars( 'has', templateName ) -> bool returns whether the template is already cached
because if ! has tpl { add tpl; render } is nicer than catching
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 withoutsync: true
,$('#foo').render('tpl', {}); $('#foo .something').whatever();
doesn't really work (except when it does).