// Backbone.Inline.Template, v1.0.1 // Copyright (c) 2016 Michael Heim, Zeilenwechsel.de // Distributed under MIT license // http://github.com/hashchange/backbone.inline.template !function(a,b){"use strict";var c="object"==typeof exports&&exports&&!exports.nodeType&&"object"==typeof module&&module&&!module.nodeType;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(["exports","underscore","backbone","backbone.declarative.views"],b):c?b(exports,require("underscore"),require("backbone"),require("backbone.declarative.views")):b({},_,Backbone)}(this,function(a,_,Backbone){"use strict";function b(a){return"inline"===a.data("el-definition")}function c(a){a.attr("data-bbit-internal-template-status","updated")}function d(a){return"updated"===a.data("bbit-internal-template-status")}function e(a){var b,c,d="",e=a.replace(k,"").replace(l,""),f=m.exec(e)||n.exec(e);if(!f)throw new Backbone.DeclarativeViews.TemplateError('Backbone.Inline.Template: Failed to parse template with inline `el` definition. No matching content found.\nTemplate text is "'+a+'"');f[3]?(b=f[1]+f[3],d=f[2]):b=f[0];try{c=h(b)}catch(c){throw new Backbone.DeclarativeViews.TemplateError('Backbone.Inline.Template: Failed to parse template with inline `el` definition. Extracted `el` could not be turned into a sample node.\nExtracted `el` definition string is "'+b+'", full template text is "'+a+'"')}return{templateContent:d,$elSample:c}}function f(a,b){var c={tagName:a.prop("tagName").toLowerCase(),className:h.trim(a.attr("class")),id:h.trim(a.attr("id")),otherAttributes:{}};_.each(a[0].attributes,function(a){var b=a.nodeName,d=a.nodeValue,e=void 0!==d&&"class"!==b&&"id"!==b;e&&(c.otherAttributes[a.nodeName]=d)}),"div"!==c.tagName&&b.attr("data-tag-name",c.tagName),c.className&&b.attr("data-class-name",c.className),c.id&&b.attr("data-id",c.id),_.size(c.otherAttributes)&&b.attr("data-attributes",JSON.stringify(c.otherAttributes))}function g(a){try{return 0!==i.find(a).length}catch(a){return!1}}var h=Backbone.$,i=h(document),j=Backbone.InlineTemplate={hasInlineEl:b,updateTemplateSource:!1,version:"1.0.1"},k=/^(\s*)+/,l=/(\s*)+$/,m=/(<\s*[a-zA-Z][\s\S]*?>)([\s\S]*)(<\s*\/\s*[a-zA-Z]+\s*>)/,n=/<\s*[a-zA-Z][\s\S]*?\/?\s*>/,o=Backbone.DeclarativeViews.defaults.loadTemplate;Backbone.DeclarativeViews.plugins.registerDataAttribute("el-definition"),Backbone.DeclarativeViews.plugins.registerDataAttribute("bbit-internal-template-status"),Backbone.DeclarativeViews.plugins.registerCacheAlias(j,"inlineTemplate"),Backbone.DeclarativeViews.plugins.enforceTemplateLoading(),Backbone.DeclarativeViews.defaults.loadTemplate=function(a){var i,k,l=j.custom.hasInlineEl||j.hasInlineEl||b,m=j.updateTemplateSource,n=o(a);if(d(n)||!l(n))k=n;else{try{i=e(n.html())}catch(b){throw b.message+='\nThe template was requested for template property "'+a+'"',b}if(m){if(!g(a))throw new Backbone.DeclarativeViews.TemplateError("Backbone.Inline.Template: Can't update the template container because it doesn't exist in the DOM. The template property must be a valid selector (and not, for instance, a raw HTML string). Instead, we got \""+a+'"');k=n,c(k)}else k=h("