!function(e){"function"==typeof define&&define.amd?define(["underscore","backbone","backbone-localStorage"],e):e(_,Backbone)}(function(e,t){var n={url:"public/templates/",ext:".hbs",version:"0.0.1",cache:!0,storage:new t.LocalStorage("Templar")};return t.Templar=function(a,o){var o="undefined"==typeof o?{}:o,i=o.ext?o.ext:n.ext,r=o.url?o.url:n.url,l=o.version?o.version:n.version,c="undefined"!=typeof o.cache?o.cache:n.cache,h=o.storage?o.storage:n.storage;this.render=function(e){if(!e.path)throw new Error("A template path is required.");e.el=e.el?e.el:document.body,d._render(e)},this.add=function(){if(!o.path)throw new Error("A template path is required.");d._add(o)};var d=new(t.Collection.extend({initialize:function(){this._loadTemplates()},templates:a,model:t.Model.extend({defaults:function(){return{path:null,content:null,version:l}},url:function(){var e=this.get("path")&&"undefined"!==this.get("path")?this.get("path"):"";return r+e+i},parse:function(e){return{content:e}}}),localStorage:h,_loadTemplates:function(){var t=this,n=this.localStorage.findAll();if(n.length>0&&n[0].version!==l&&(c=!1),c)for(var a=0;a0?this._compile(a[0].get("content"),t.el,t.append,t.data,t.cb):this._add(t,e.bind(function(){n._compile(templateModel.get("content"),t.el,t.append,t.data,t.cb)},this))}}))},t.Templar});