From 8935e352a20f5838e3d5755b8b3927c2ef1e593b Mon Sep 17 00:00:00 2001
From: sorenwojo
Date: Thu, 21 Jan 2016 16:42:54 +0100
Subject: [PATCH 01/20] Fire afterInsert when item from array has been inserted
Added different handling of afterInsert event when data is an array.
When data is not an array event will be fired as before.
---
.../jquery.loadTemplate-1.5.0.js | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
index 209cfa3..d0f8954 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
@@ -2,7 +2,8 @@
"use strict";
var templates = {},
queue = {},
- formatters = {};
+ formatters = {},
+ isArray;
function loadTemplate(template, data, options) {
var $that = this,
@@ -39,6 +40,7 @@
}, options);
if ($.type(data) === "array") {
+ isArray = true;
return processArray.call(this, template, data, settings);
}
@@ -97,12 +99,16 @@
settings,
{
async: false,
- complete: function () {
+ complete: function (data) {
if (this.html) {
+ var insertedElement;
if (doPrepend) {
- $that.prepend(this.html());
+ insertedElement = $(this.html()).prependTo($that);
} else {
- $that.append(this.html());
+ insertedElement = $(this.html()).appendTo($that);
+ }
+ if (settings.afterInsert && data) {
+ settings.afterInsert(insertedElement, data);
}
}
done++;
@@ -228,13 +234,13 @@
} else {
$(this).html($templateHtml);
}
- if (settings.afterInsert) {
+ if (settings.afterInsert && !isArray) {
settings.afterInsert($templateHtml, data);
}
});
if (typeof settings.complete === "function") {
- settings.complete.call($(this));
+ settings.complete.call($(this), data);
}
}
From 501ce5b1c491a66c247866f3321c9416550e23ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20J=C3=B8rgensen?=
Date: Fri, 29 Jan 2016 22:43:58 +0100
Subject: [PATCH 02/20] Fixed failing test
Moved incrementation of counter to before comparison as template now has been added when event is fired.
---
tests/files/callback.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/files/callback.js b/tests/files/callback.js
index b9899d4..40abd43 100644
--- a/tests/files/callback.js
+++ b/tests/files/callback.js
@@ -49,12 +49,12 @@
afterInsert : function(elem){
sequence.push('after');
+ ++afterInsertCounter;
+
if ($('#render').children().length === afterInsertCounter) {
elemSequence.push(true);
}
-
- ++afterInsertCounter;
-
+
},
complete : function(){
sequence.push('complete');
From 3c0dadf03e6ef99940f41bcc27825bed982eed6f Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 09:54:13 +0000
Subject: [PATCH 03/20] Updating version
---
Examples/index.html | 2 +-
bower.json | 2 +-
jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js | 1 -
...query.loadTemplate-1.5.0.js => jquery.loadTemplate-1.5.1.js} | 0
jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js | 1 +
loadTemplate.jquery.json | 2 +-
package.json | 2 +-
tests/index.html | 2 +-
8 files changed, 6 insertions(+), 6 deletions(-)
delete mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.0.js => jquery.loadTemplate-1.5.1.js} (100%)
create mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js
diff --git a/Examples/index.html b/Examples/index.html
index d12c8a1..a5b2e3c 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index 19cae22..dda5299 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery-load-template",
- "version": "1.5.0",
+ "version": "1.5.1",
"authors": [
{ "name": "Paul Burgess"}
],
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js
deleted file mode 100644
index 1333b7b..0000000
--- a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(a){var v={},u={},h={};function n(F,B,D){var A=this,z,C,E;B=B||{};E=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(E.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},D);if(a.type(B)==="array"){return s.call(this,F,B,E)}if(!g(F)){z=a(F);if(typeof F==="string"&&F.indexOf("#")===0){E.isFile=false}}C=E.isFile||(typeof E.isFile==="undefined"&&(typeof z==="undefined"||z.length===0));if(C&&!E.overwriteCache&&v[F]){q(F,A,B,E)}else{if(C&&!E.overwriteCache&&v.hasOwnProperty(F)){c(F,A,B,E)}else{if(C){m(F,A,B,E)}else{o(z,A,B,E)}}}return this}function b(A,z){if(z){h[A]=z}else{h=a.extend(h,A)}}function g(z){return typeof z==="string"&&z.indexOf("/")>-1}function s(J,A,G){G=G||{};var z=this,K=A.length,C=G.prepend&&!G.append,B=0,I=0,D=false,E=[],F;if(G.paged){var H=(G.pageNo-1)*G.elemPerPage;A=A.slice(H,H+G.elemPerPage);K=A.length}F=a.extend({},G,{async:false,complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===K||D){if(D&&G&&typeof G.error==="function"){G.error.call(z,E)}if(G&&typeof G.complete==="function"){G.complete()}}},success:function(){I++;if(I===K){if(G&&typeof G.success==="function"){G.success()}}},error:function(L){D=true;E.push(L)}});if(!G.append&&!G.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var L=a("
");n.call(L,J,this,F);if(D){return false}});return this}function c(C,A,z,B){if(u[C]){u[C].push({data:z,selection:A,settings:B})}else{u[C]=[{data:z,selection:A,settings:B}]}}function q(D,B,A,C){var z=v[D].clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success()}}function w(){return new Date().getTime()}function x(z){if(z.indexOf("?")!==-1){return z+"&_="+w()}else{return z+"?_="+w()}}function m(D,B,A,C){var z=a("
");v[D]=null;var E=D;if(C.overwriteCache){E=x(E)}a.ajax({url:E,async:C.async,success:function(F){z.html(F);l(z,D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function o(z,C,B,D){var A=a("
");if(z.is("script")||z.is("template")){z=a.parseHTML(a.trim(z.html()))}A.html(z);p.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function p(B,z,A){f(B,z,A);a(this).each(function(){var C=a(B.html());if(A.beforeInsert){A.beforeInsert(C,z)}if(A.append){a(this).append(C)}else{if(A.prepend){a(this).prepend(C)}else{a(this).html(C)}}if(A.afterInsert){A.afterInsert(C,z)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(D,B,z,C,A){var E;if(typeof C.error==="function"){C.error.call(B,A)}a(u[D]).each(function(F,G){if(typeof G.settings.error==="function"){G.settings.error.call(G.selection,A)}});if(typeof C.complete==="function"){C.complete.call(B)}while(u[D]&&(E=u[D].shift())){if(typeof E.settings.complete==="function"){E.settings.complete.call(E.selection)}}if(typeof u[D]!=="undefined"&&u[D].length>0){u[D]=[]}}function l(z,D,B,A,C){var E;v[D]=z.clone();p.call(B,z,A,C);if(typeof C.success==="function"){C.success.call(B)}while(u[D]&&(E=u[D].shift())){p.call(E.selection,v[D].clone(),E.data,E.settings);if(typeof E.settings.success==="function"){E.settings.success.call(E.selection)}}}function f(B,z,A){z=z||{};t("data-content",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-content-append",B,z,A,function(C,D){C.append(e(C,D,"content",A))});t("data-content-prepend",B,z,A,function(C,D){C.prepend(e(C,D,"content",A))});t("data-content-text",B,z,A,function(C,D){C.text(e(C,D,"content",A))});t("data-innerHTML",B,z,A,function(C,D){C.html(e(C,D,"content",A))});t("data-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",A))},function(C){C.remove()});t("data-href",B,z,A,function(C,D){C.attr("href",e(C,D,"href",A))},function(C){C.remove()});t("data-alt",B,z,A,function(C,D){C.attr("alt",e(C,D,"alt",A))});t("data-id",B,z,A,function(C,D){C.attr("id",e(C,D,"id",A))});t("data-value",B,z,A,function(C,D){C.attr("value",e(C,D,"value",A))});t("data-class",B,z,A,function(C,D){C.addClass(e(C,D,"class",A))});t("data-link",B,z,A,function(C,E){var D=a("
");D.attr("href",e(C,E,"link",A));D.html(C.html());C.html(D)});t("data-link-wrap",B,z,A,function(C,E){var D=a("
");D.attr("href",e(C,E,"link-wrap",A));C.wrap(D)});t("data-options",B,z,A,function(C,D){a(D).each(function(){var E=a("
");E.attr("value",this).text(this).appendTo(C)})});r(B,z,A)}function t(z,E,A,D,B,C){a("["+z+"]",E).each(function(){var F=a(this),G=F.attr(z),H=j(A,G);if(!y(F,H,D)){F.remove();return}F.removeAttr(z);if(typeof H!=="undefined"&&B){B(F,H)}else{if(C){C(F)}}});return}function y(A,C,B){var z=i(A,B);if(z.ignoreUndefined&&typeof C==="undefined"){return false}else{if(z.ignoreNull&&C===null){return false}else{if(z.ignoreEmptyString&&C===""){return false}else{return true}}}}function i(A,B){var z={};if(A instanceof jQuery&&A.attr("data-binding-options")){z=a.parseJSON(A.attr("data-binding-options"));A.removeAttr("data-binding-options")}else{if(typeof A==="object"&&A.hasOwnProperty("bindingOptions")){z=A.bindingOptions}}return a.extend({},B.bindingOptions,z)}function r(B,z,A){a("[data-template-bind]",B).each(function(){var C=a(this),D=a.parseJSON(C.attr("data-template-bind"));C.removeAttr("data-template-bind");a(D).each(function(){var F;if(typeof(this.value)==="object"){F=j(z,this.value.data)}else{F=j(z,this.value)}if(this.attribute){if(!y(this,F,A)){C.remove();return}switch(this.attribute){case"content":case"innerHTML":C.html(d(C,F,this));break;case"contentAppend":C.append(d(C,F,this));break;case"contentPrepend":C.prepend(d(C,F,this));break;case"contentText":C.text(d(C,F,this));break;case"options":var E=this;a(F).each(function(){var G=a("
");G.attr("value",this[E.value.value]).text(d(C,this[E.value.content],E)).attr("selected",typeof this[E.value.selected]==undefined?false:this[E.value.selected]).appendTo(C)});break;default:C.attr(this.attribute,d(C,F,this))}}})})}function d(z,C,A,B){if(A.formatter&&h[A.formatter]){return(function(D){return h[A.formatter].call(z,C,A.formatOptions,D)})(B)}return C}function j(z,A){if(A==="this"){return z}var B=A.split("."),C,D=z;while((C=B.shift())&&typeof D!=="undefined"&&D!=null){D=D[C]}return D}function e(z,F,A,E){var D=z.attr("data-format-target"),C;if(D===A||(!D&&A==="content")){C=z.attr("data-format");if(C&&typeof h[C]==="function"){var B=z.attr("data-format-options");return(function(G){return h[C].call(z[0],F,B,a.extend({},G))})(E)}}return F}b("nestedTemplateFormatter",function(D,A,z){if(!A){return}if(typeof A==="string"&&A[0]==="{"){A=a.parseJSON(A)}var B=A.parentElement||"div";var C=A.template||A;if(A.parentElement){return a("<"+B+"/>").loadTemplate(C,D,z)}else{return a("<"+B+"/>").loadTemplate(C,D,z).children()}});a.fn.loadTemplate=n;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.1.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.1.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js
new file mode 100644
index 0000000..7c30cb8
--- /dev/null
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js
@@ -0,0 +1 @@
+(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}G=a.extend({},H,{async:false,complete:function(M){if(this.html){var N;if(D){N=a(this.html()).prependTo(A)}else{N=a(this.html()).appendTo(A)}if(H.afterInsert&&M){H.afterInsert(N,M)}}C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(!H.append&&!H.prepend){A.html("")}if(D){B.reverse()}a(B).each(function(){var M=a("
");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C.html());if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-value",C,A,B,function(D,E){D.attr("value",e(D,E,"value",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B)}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 383ad61..be5219b 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.0",
+ "version": "1.5.1",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index a1ac9c4..b4133f8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.0",
+ "version": "1.5.1",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index e70f28a..eda91b2 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 0004f1d068c15173cb2e2b77fd1c4be0f2d2afa0 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 11:00:13 +0000
Subject: [PATCH 04/20] updating bower.json
---
Examples/index.html | 2 +-
bower.json | 4 +---
...ery.loadTemplate-1.5.1.js => jquery.loadTemplate-1.5.2.js} | 0
...Template-1.5.1.min.js => jquery.loadTemplate-1.5.2.min.js} | 0
loadTemplate.jquery.json | 2 +-
package.json | 2 +-
tests/index.html | 2 +-
7 files changed, 5 insertions(+), 7 deletions(-)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.1.js => jquery.loadTemplate-1.5.2.js} (100%)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.1.min.js => jquery.loadTemplate-1.5.2.min.js} (100%)
diff --git a/Examples/index.html b/Examples/index.html
index a5b2e3c..4b46dbe 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index dda5299..6940479 100644
--- a/bower.json
+++ b/bower.json
@@ -1,16 +1,14 @@
{
"name": "jquery-load-template",
- "version": "1.5.1",
"authors": [
{ "name": "Paul Burgess"}
],
"homepage": "http://codepb.github.io/jquery-template/",
"repository": {
"type": "git",
- "url": "git://github.com/codepb/jquery-template.git"
+ "url": "https://github.com/codepb/jquery-template.git"
},
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
- "main": "jquery-loadTemplate/jquery.loadTemplate.js",
"ignore": [
"Examples",
"tests",
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.1.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.2.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.1.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.2.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.1.min.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index be5219b..6ed8bf6 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.1",
+ "version": "1.5.2",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index b4133f8..15ab0af 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.1",
+ "version": "1.5.2",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index eda91b2..3c74f9e 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 538aad652d4e16eba1e88488e94980456df4d61c Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 11:12:34 +0000
Subject: [PATCH 05/20] Attempting to fix bower.json
---
Examples/index.html | 2 +-
bower.json | 19 ++++++++++---------
...-1.5.2.js => jquery.loadTemplate-1.5.3.js} | 0
...in.js => jquery.loadTemplate-1.5.3.min.js} | 0
loadTemplate.jquery.json | 2 +-
package.json | 2 +-
tests/index.html | 2 +-
7 files changed, 14 insertions(+), 13 deletions(-)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.2.js => jquery.loadTemplate-1.5.3.js} (100%)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.2.min.js => jquery.loadTemplate-1.5.3.min.js} (100%)
diff --git a/Examples/index.html b/Examples/index.html
index 4b46dbe..8303ace 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index 6940479..d90121b 100644
--- a/bower.json
+++ b/bower.json
@@ -1,31 +1,32 @@
{
"name": "jquery-load-template",
+ "homepage": "http://codepb.github.io/jquery-template/",
"authors": [
- { "name": "Paul Burgess"}
+ ["Paul Burgess
"]
],
- "homepage": "http://codepb.github.io/jquery-template/",
+ "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"repository": {
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
+ "main": "jquery-loadTemplate-1.5.3.js"
+ "keywords": [
+ "templates",
+ "templating",
+ "jquery-plugin"
+ ],
"ignore": [
"Examples",
"tests",
".gitattributes",
".gitignore",
".travis.yml",
- "bower.json",
"loadTemplate.jquery.json",
"MIT-LICENSE.txt",
"package.json",
"readme.md"
],
- "keywords": [
- "templates",
- "templating",
- "jquery-plugin"
- ],
+
"dependencies": {
"jquery": ">=1.8"
}
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.2.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.3.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.2.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.3.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.2.min.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 6ed8bf6..6d5588b 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.2",
+ "version": "1.5.3",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index 15ab0af..04cc460 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.2",
+ "version": "1.5.3",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 3c74f9e..005ff3b 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From d32135f3bf98312bf139afb765abf07fb962a910 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 11:15:49 +0000
Subject: [PATCH 06/20] Fixed issue with author tag in bower.json
---
Examples/index.html | 2 +-
bower.json | 7 +++----
....loadTemplate-1.5.3.js => jquery.loadTemplate-1.5.4.js} | 0
...plate-1.5.3.min.js => jquery.loadTemplate-1.5.4.min.js} | 0
loadTemplate.jquery.json | 2 +-
package.json | 2 +-
tests/index.html | 2 +-
7 files changed, 7 insertions(+), 8 deletions(-)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.3.js => jquery.loadTemplate-1.5.4.js} (100%)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.3.min.js => jquery.loadTemplate-1.5.4.min.js} (100%)
diff --git a/Examples/index.html b/Examples/index.html
index 8303ace..d0af2e8 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index d90121b..49b4d26 100644
--- a/bower.json
+++ b/bower.json
@@ -2,14 +2,14 @@
"name": "jquery-load-template",
"homepage": "http://codepb.github.io/jquery-template/",
"authors": [
- ["Paul Burgess
"]
+ "Paul Burgess "
],
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"repository": {
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "jquery-loadTemplate-1.5.3.js"
+ "main": "jquery.loadTemplate-1.5.4.js"
"keywords": [
"templates",
"templating",
@@ -25,8 +25,7 @@
"MIT-LICENSE.txt",
"package.json",
"readme.md"
- ],
-
+ ],
"dependencies": {
"jquery": ">=1.8"
}
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.4.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.3.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.4.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.3.min.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 6d5588b..7183432 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.3",
+ "version": "1.5.4",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index 04cc460..7b1f717 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.3",
+ "version": "1.5.4",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 005ff3b..2c10302 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From ae7ffa01cfd399853923348b630180c116337e34 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 11:19:06 +0000
Subject: [PATCH 07/20] fixed missing comma after main in bower.json
---
bower.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bower.json b/bower.json
index 49b4d26..4b5dbb2 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "jquery.loadTemplate-1.5.4.js"
+ "main": "jquery.loadTemplate-1.5.4.js",
"keywords": [
"templates",
"templating",
From 98b5eb84b4a948228b3bf4aa93160d44bcd5ff12 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 11:20:30 +0000
Subject: [PATCH 08/20] Updating Version
---
Examples/index.html | 2 +-
bower.json | 2 +-
...query.loadTemplate-1.5.4.js => jquery.loadTemplate-1.5.5.js} | 0
...adTemplate-1.5.4.min.js => jquery.loadTemplate-1.5.5.min.js} | 0
loadTemplate.jquery.json | 2 +-
package.json | 2 +-
tests/index.html | 2 +-
7 files changed, 5 insertions(+), 5 deletions(-)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.4.js => jquery.loadTemplate-1.5.5.js} (100%)
rename jquery-loadTemplate/{jquery.loadTemplate-1.5.4.min.js => jquery.loadTemplate-1.5.5.min.js} (100%)
diff --git a/Examples/index.html b/Examples/index.html
index d0af2e8..f09337f 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index 4b5dbb2..e9ad1c0 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "jquery.loadTemplate-1.5.4.js",
+ "main": "jquery.loadTemplate-1.5.5.js",
"keywords": [
"templates",
"templating",
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.4.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.5.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.4.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.5.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.4.min.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 7183432..6f8ac34 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.4",
+ "version": "1.5.5",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index 7b1f717..ba1a933 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.4",
+ "version": "1.5.5",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 2c10302..50e6ddf 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 54c882c2aefa361e6faa7cdfc6abcf8c68bd505b Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Mon, 29 Feb 2016 11:31:33 +0000
Subject: [PATCH 09/20] moved to a new dist folder. New version
---
.gitignore | 1 -
Examples/index.html | 2 +-
bower.json | 2 +-
.../jquery.loadTemplate-1.5.6.js | 0
.../jquery.loadTemplate-1.5.6.min.js | 0
loadTemplate.jquery.json | 2 +-
package.json | 2 +-
tests/index.html | 2 +-
8 files changed, 5 insertions(+), 6 deletions(-)
rename jquery-loadTemplate/jquery.loadTemplate-1.5.5.js => dist/jquery.loadTemplate-1.5.6.js (100%)
rename jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js => dist/jquery.loadTemplate-1.5.6.min.js (100%)
diff --git a/.gitignore b/.gitignore
index b9d6bd9..38a363a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -192,7 +192,6 @@ $RECYCLE.BIN/
# Packages
*.egg
*.egg-info
-dist/
build/
eggs/
parts/
diff --git a/Examples/index.html b/Examples/index.html
index f09337f..6d1388a 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index e9ad1c0..1c946fa 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "jquery.loadTemplate-1.5.5.js",
+ "main": "dist/jquery.loadTemplate-1.5.6.js",
"keywords": [
"templates",
"templating",
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.5.js b/dist/jquery.loadTemplate-1.5.6.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.5.js
rename to dist/jquery.loadTemplate-1.5.6.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js b/dist/jquery.loadTemplate-1.5.6.min.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.5.5.min.js
rename to dist/jquery.loadTemplate-1.5.6.min.js
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 6f8ac34..d8a6eea 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.5",
+ "version": "1.5.6",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index ba1a933..a9339ae 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.5",
+ "version": "1.5.6",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 50e6ddf..2b0a61d 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 6733ea1c0e05f421fe5e9c43bd2bb1df3e6fde27 Mon Sep 17 00:00:00 2001
From: codepb
Date: Tue, 8 Mar 2016 21:27:51 +0000
Subject: [PATCH 10/20] fixing reference to data-format-template
fixes #90
---
readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index b8cb88b..7a6d4bd 100644
--- a/readme.md
+++ b/readme.md
@@ -64,7 +64,7 @@ You can pass an array of objects instead of a single object and the template wil
### Data Formatters
-It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-template may be empty. Example usage of this is below:
+It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-options may be empty. Example usage of this is below:
$.addTemplateFormatter("UpperCaseFormatter",
function(value, template) {
From c57638100d464d9ecd33c4a53b2c80121daafc6a Mon Sep 17 00:00:00 2001
From: Michal Brauner
Date: Fri, 25 Mar 2016 19:42:35 +0100
Subject: [PATCH 11/20] fix package.json - missing "main" option
---
package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/package.json b/package.json
index a9339ae..ad8504e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
{
"name": "jquery.loadtemplate",
"version": "1.5.6",
+ "main": "dist/jquery.loadTemplate-1.5.6.js",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
From 62bb1f012f974b8961a73fe77784155b90806815 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Fri, 1 Apr 2016 16:24:21 +0100
Subject: [PATCH 12/20] Fixed issue with binding the value of selects
now uses .val to bind value. Fixed templates so the javascript
properties are also copied with the template into the dom
---
Examples/SimpleExample/Templates/simple.html | 2 +-
Examples/SimpleExample/example.html | 4 +++-
Examples/index.html | 4 ++--
bower.json | 2 +-
dist/jquery.loadTemplate-1.5.6.min.js | 1 -
...-1.5.6.js => jquery.loadTemplate-1.5.7.js} | 21 ++++++++++++-------
dist/jquery.loadTemplate-1.5.7.min.js | 1 +
loadTemplate.jquery.json | 2 +-
package.json | 4 ++--
tests/index.html | 2 +-
10 files changed, 26 insertions(+), 17 deletions(-)
delete mode 100644 dist/jquery.loadTemplate-1.5.6.min.js
rename dist/{jquery.loadTemplate-1.5.6.js => jquery.loadTemplate-1.5.7.js} (97%)
create mode 100644 dist/jquery.loadTemplate-1.5.7.min.js
diff --git a/Examples/SimpleExample/Templates/simple.html b/Examples/SimpleExample/Templates/simple.html
index c844792..2e75af5 100644
--- a/Examples/SimpleExample/Templates/simple.html
+++ b/Examples/SimpleExample/Templates/simple.html
@@ -3,7 +3,7 @@
-
+
Example of loading a template from a script tag within the same document.
-
+
@@ -81,7 +81,7 @@
Code
$($div).load($(this).attr("href"), function () {
$(".contentContainer > div").hide();
$(".codeContainer > div").hide();
- $(".contentContainer div.content").html($div.html());
+ $(".contentContainer div.content").html("").append($div);
$(".codeContainer pre code").text($div.html());
if(highlightSupported()) {
$(".codeContainer pre code").each(function () {
diff --git a/bower.json b/bower.json
index 1c946fa..0387819 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "dist/jquery.loadTemplate-1.5.6.js",
+ "main": "dist/jquery.loadTemplate-1.5.7.js",
"keywords": [
"templates",
"templating",
diff --git a/dist/jquery.loadTemplate-1.5.6.min.js b/dist/jquery.loadTemplate-1.5.6.min.js
deleted file mode 100644
index 7c30cb8..0000000
--- a/dist/jquery.loadTemplate-1.5.6.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}G=a.extend({},H,{async:false,complete:function(M){if(this.html){var N;if(D){N=a(this.html()).prependTo(A)}else{N=a(this.html()).appendTo(A)}if(H.afterInsert&&M){H.afterInsert(N,M)}}C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(!H.append&&!H.prepend){A.html("")}if(D){B.reverse()}a(B).each(function(){var M=a("
");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C.html());if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-value",C,A,B,function(D,E){D.attr("value",e(D,E,"value",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B)}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/dist/jquery.loadTemplate-1.5.6.js b/dist/jquery.loadTemplate-1.5.7.js
similarity index 97%
rename from dist/jquery.loadTemplate-1.5.6.js
rename to dist/jquery.loadTemplate-1.5.7.js
index d0f8954..7f6df6e 100644
--- a/dist/jquery.loadTemplate-1.5.6.js
+++ b/dist/jquery.loadTemplate-1.5.7.js
@@ -103,9 +103,9 @@
if (this.html) {
var insertedElement;
if (doPrepend) {
- insertedElement = $(this.html()).prependTo($that);
+ insertedElement = $(this).prependTo($that);
} else {
- insertedElement = $(this.html()).appendTo($that);
+ insertedElement = $(this).appendTo($that);
}
if (settings.afterInsert && data) {
settings.afterInsert(insertedElement, data);
@@ -222,7 +222,10 @@
bindData(template, data, settings);
$(this).each(function () {
- var $templateHtml = $(template.html());
+ var $templateHtml = template.clone(true);
+ $("select", $templateHtml).each(function (key, value) {
+ $(this).val($("select", template).eq(key).val())
+ });
if (settings.beforeInsert) {
settings.beforeInsert($templateHtml, data);
}
@@ -232,7 +235,7 @@
} else if (settings.prepend) {
$(this).prepend($templateHtml);
} else {
- $(this).html($templateHtml);
+ $(this).html("").append($templateHtml);
}
if (settings.afterInsert && !isArray) {
settings.afterInsert($templateHtml, data);
@@ -333,9 +336,7 @@
$elem.attr("id", applyFormatters($elem, value, "id", settings));
});
- processElements("data-value", template, data, settings, function ($elem, value) {
- $elem.attr("value", applyFormatters($elem, value, "value", settings));
- });
+
processElements("data-class", template, data, settings, function ($elem, value) {
$elem.addClass(applyFormatters($elem, value, "class", settings));
@@ -362,6 +363,12 @@
});
processAllElements(template, data, settings);
+
+ processElements("data-value", template, data, settings, function ($elem, value) {
+ $elem.val(applyFormatters($elem, value, "value", settings));
+ });
+
+
}
function processElements(attribute, template, data, settings, dataBindFunction, noDataFunction) {
diff --git a/dist/jquery.loadTemplate-1.5.7.min.js b/dist/jquery.loadTemplate-1.5.7.min.js
new file mode 100644
index 0000000..22b6087
--- /dev/null
+++ b/dist/jquery.loadTemplate-1.5.7.min.js
@@ -0,0 +1 @@
+(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}G=a.extend({},H,{async:false,complete:function(M){if(this.html){var N;if(D){N=a(this).prependTo(A)}else{N=a(this).appendTo(A)}if(H.afterInsert&&M){H.afterInsert(N,M)}}C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(!H.append&&!H.prepend){A.html("")}if(D){B.reverse()}a(B).each(function(){var M=a("
");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=C.clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index d8a6eea..355d7cf 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.6",
+ "version": "1.5.7",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index ad8504e..4ee801a 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.6",
- "main": "dist/jquery.loadTemplate-1.5.6.js",
+ "version": "1.5.7",
+ "main": "dist/jquery.loadTemplate-1.5.7.js",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 2b0a61d..fc69b5b 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From fbcd04eab22720106307a18e567961055b2788ca Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Tue, 5 Jul 2016 21:03:46 +0100
Subject: [PATCH 13/20] fixed issue with div wrapper on arrays
resolves #101
---
.gitignore | 3 ++
Examples/index.html | 2 +-
bower.json | 2 +-
dist/jquery.loadTemplate-1.5.7.min.js | 1 -
...-1.5.7.js => jquery.loadTemplate-1.5.8.js} | 39 +++++++------------
dist/jquery.loadTemplate-1.5.8.min.js | 1 +
loadTemplate.jquery.json | 2 +-
package.json | 4 +-
tests/index.html | 2 +-
9 files changed, 23 insertions(+), 33 deletions(-)
delete mode 100644 dist/jquery.loadTemplate-1.5.7.min.js
rename dist/{jquery.loadTemplate-1.5.7.js => jquery.loadTemplate-1.5.8.js} (94%)
create mode 100644 dist/jquery.loadTemplate-1.5.8.min.js
diff --git a/.gitignore b/.gitignore
index 38a363a..3835d69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+bower_components/
+node_modules/
+
#################
## Eclipse
#################
diff --git a/Examples/index.html b/Examples/index.html
index f90b3a0..236df63 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index 0387819..e8f401f 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "dist/jquery.loadTemplate-1.5.7.js",
+ "main": "dist/jquery.loadTemplate-1.5.8.js",
"keywords": [
"templates",
"templating",
diff --git a/dist/jquery.loadTemplate-1.5.7.min.js b/dist/jquery.loadTemplate-1.5.7.min.js
deleted file mode 100644
index 22b6087..0000000
--- a/dist/jquery.loadTemplate-1.5.7.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}G=a.extend({},H,{async:false,complete:function(M){if(this.html){var N;if(D){N=a(this).prependTo(A)}else{N=a(this).appendTo(A)}if(H.afterInsert&&M){H.afterInsert(N,M)}}C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(!H.append&&!H.prepend){A.html("")}if(D){B.reverse()}a(B).each(function(){var M=a("
");o.call(M,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(E,C,B,D){var A=a("
");w[E]=null;var F=E;if(D.overwriteCache){F=y(F)}a.ajax({url:F,async:D.async,success:function(G){A.html(G);l(A,E,C,B,D)},error:function(G){k(E,C,B,D,G)}})}function p(A,D,C,E){var B=a("
");if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}B.html(A);q.call(D,B,C,E);if(typeof E.success==="function"){E.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=C.clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/dist/jquery.loadTemplate-1.5.7.js b/dist/jquery.loadTemplate-1.5.8.js
similarity index 94%
rename from dist/jquery.loadTemplate-1.5.7.js
rename to dist/jquery.loadTemplate-1.5.8.js
index 7f6df6e..fc3656d 100644
--- a/dist/jquery.loadTemplate-1.5.7.js
+++ b/dist/jquery.loadTemplate-1.5.8.js
@@ -94,23 +94,17 @@
todo = data.length;
}
+ if (!settings.append && !settings.prepend) {
+ $that.html("");
+ }
+
newOptions = $.extend(
{},
settings,
{
async: false,
+ append: !settings.prepend && true,
complete: function (data) {
- if (this.html) {
- var insertedElement;
- if (doPrepend) {
- insertedElement = $(this).prependTo($that);
- } else {
- insertedElement = $(this).appendTo($that);
- }
- if (settings.afterInsert && data) {
- settings.afterInsert(insertedElement, data);
- }
- }
done++;
if (done === todo || errored) {
if (errored && settings && typeof settings.error === "function") {
@@ -136,14 +130,12 @@
}
);
- if (!settings.append && !settings.prepend) {
- $that.html("");
- }
+
if (doPrepend) data.reverse();
$(data).each(function () {
- var $div = $("
");
- loadTemplate.call($div, template, this, newOptions);
+
+ loadTemplate.call($that, template, this, newOptions);
if (errored) {
return false;
}
@@ -183,7 +175,6 @@
}
function loadAndPrepareTemplate(template, selection, data, settings) {
- var $templateContainer = $("
");
templates[template] = null;
var templateUrl = template;
@@ -194,8 +185,7 @@
url: templateUrl,
async: settings.async,
success: function (templateContent) {
- $templateContainer.html(templateContent);
- handleTemplateLoadingSuccess($templateContainer, template, selection, data, settings);
+ handleTemplateLoadingSuccess($(templateContent), template, selection, data, settings);
},
error: function (e) {
handleTemplateLoadingError(template, selection, data, settings, e);
@@ -204,14 +194,11 @@
}
function loadTemplateFromDocument($template, selection, data, settings) {
- var $templateContainer = $("
");
-
if ($template.is("script") || $template.is("template")) {
$template = $.parseHTML($.trim($template.html()));
}
- $templateContainer.html($template);
- prepareTemplate.call(selection, $templateContainer, data, settings);
+ prepareTemplate.call(selection, $template, data, settings);
if (typeof settings.success === "function") {
settings.success();
@@ -222,7 +209,7 @@
bindData(template, data, settings);
$(this).each(function () {
- var $templateHtml = template.clone(true);
+ var $templateHtml = $(template).clone(true);
$("select", $templateHtml).each(function (key, value) {
$(this).val($("select", template).eq(key).val())
});
@@ -372,7 +359,7 @@
}
function processElements(attribute, template, data, settings, dataBindFunction, noDataFunction) {
- $("[" + attribute + "]", template).each(function () {
+ $("[" + attribute + "]", $("
").append(template)).each(function () {
var $this = $(this),
param = $this.attr(attribute),
value = getValue(data, param);
@@ -431,7 +418,7 @@
}
function processAllElements(template, data, settings) {
- $("[data-template-bind]", template).each(function () {
+ $("[data-template-bind]", $("
").append(template)).each(function () {
var $this = $(this),
param = $.parseJSON($this.attr("data-template-bind"));
diff --git a/dist/jquery.loadTemplate-1.5.8.min.js b/dist/jquery.loadTemplate-1.5.8.min.js
new file mode 100644
index 0000000..b1b6793
--- /dev/null
+++ b/dist/jquery.loadTemplate-1.5.8.min.js
@@ -0,0 +1 @@
+(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C).clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",a("
").append(F)).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",a("
").append(C)).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 355d7cf..3e5feb9 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.7",
+ "version": "1.5.8",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index 4ee801a..8b5967c 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.7",
- "main": "dist/jquery.loadTemplate-1.5.7.js",
+ "version": "1.5.8",
+ "main": "dist/jquery.loadTemplate-1.5.8.js",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index fc69b5b..0c58d45 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 5e336807bfe62195e8369ad24ca25e888c496532 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Tue, 5 Jul 2016 21:40:26 +0100
Subject: [PATCH 14/20] Fixing issues with callbacks and binding options
Fixed issue where after insert wasn't called on array, and ensuring
binding options remove the element when the condition is matched
---
Examples/index.html | 2 +-
bower.json | 2 +-
dist/jquery.loadTemplate-1.5.8.min.js | 1 -
...oadTemplate-1.5.8.js => jquery.loadTemplate-1.5.9.js} | 9 +++++----
dist/jquery.loadTemplate-1.5.9.min.js | 1 +
loadTemplate.jquery.json | 2 +-
package.json | 4 ++--
tests/index.html | 2 +-
8 files changed, 12 insertions(+), 11 deletions(-)
delete mode 100644 dist/jquery.loadTemplate-1.5.8.min.js
rename dist/{jquery.loadTemplate-1.5.8.js => jquery.loadTemplate-1.5.9.js} (98%)
create mode 100644 dist/jquery.loadTemplate-1.5.9.min.js
diff --git a/Examples/index.html b/Examples/index.html
index 236df63..9fe41f0 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index e8f401f..2e75fef 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "dist/jquery.loadTemplate-1.5.8.js",
+ "main": "dist/jquery.loadTemplate-1.5.9.js",
"keywords": [
"templates",
"templating",
diff --git a/dist/jquery.loadTemplate-1.5.8.min.js b/dist/jquery.loadTemplate-1.5.8.min.js
deleted file mode 100644
index b1b6793..0000000
--- a/dist/jquery.loadTemplate-1.5.8.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){f(C,A,B);a(this).each(function(){var D=a(C).clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert&&!m){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",a("
").append(F)).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",a("
").append(C)).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/dist/jquery.loadTemplate-1.5.8.js b/dist/jquery.loadTemplate-1.5.9.js
similarity index 98%
rename from dist/jquery.loadTemplate-1.5.8.js
rename to dist/jquery.loadTemplate-1.5.9.js
index fc3656d..2c272ea 100644
--- a/dist/jquery.loadTemplate-1.5.8.js
+++ b/dist/jquery.loadTemplate-1.5.9.js
@@ -206,10 +206,11 @@
}
function prepareTemplate(template, data, settings) {
+ var template = $("
").append(template);
bindData(template, data, settings);
$(this).each(function () {
- var $templateHtml = $(template).clone(true);
+ var $templateHtml = template.children().clone(true);
$("select", $templateHtml).each(function (key, value) {
$(this).val($("select", template).eq(key).val())
});
@@ -224,7 +225,7 @@
} else {
$(this).html("").append($templateHtml);
}
- if (settings.afterInsert && !isArray) {
+ if (settings.afterInsert) {
settings.afterInsert($templateHtml, data);
}
});
@@ -359,7 +360,7 @@
}
function processElements(attribute, template, data, settings, dataBindFunction, noDataFunction) {
- $("[" + attribute + "]", $("
").append(template)).each(function () {
+ $("[" + attribute + "]", template).each(function () {
var $this = $(this),
param = $this.attr(attribute),
value = getValue(data, param);
@@ -418,7 +419,7 @@
}
function processAllElements(template, data, settings) {
- $("[data-template-bind]", $("
").append(template)).each(function () {
+ $("[data-template-bind]", template).each(function () {
var $this = $(this),
param = $.parseJSON($this.attr("data-template-bind"));
diff --git a/dist/jquery.loadTemplate-1.5.9.min.js b/dist/jquery.loadTemplate-1.5.9.min.js
new file mode 100644
index 0000000..8488916
--- /dev/null
+++ b/dist/jquery.loadTemplate-1.5.9.min.js
@@ -0,0 +1 @@
+(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){var C=a("
").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 3e5feb9..0a19894 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.8",
+ "version": "1.5.9",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index 8b5967c..4289f28 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.8",
- "main": "dist/jquery.loadTemplate-1.5.8.js",
+ "version": "1.5.9",
+ "main": "dist/jquery.loadTemplate-1.5.9.js",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 0c58d45..1d51108 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From f9fb1a98f0ff2501776bb16f318ec39b97b1ab1f Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Wed, 6 Jul 2016 21:25:04 +0100
Subject: [PATCH 15/20] Fixed sync ajax warning when processing array
Resolves #88. Also removed semantic versioning from file names.
---
Examples/index.html | 2 +-
bower.json | 2 +-
dist/jquery.loadTemplate-1.5.9.min.js | 1 -
dist/{jquery.loadTemplate-1.5.9.js => jquery.loadTemplate.js} | 1 -
dist/jquery.loadTemplate.min.js | 1 +
loadTemplate.jquery.json | 2 +-
package.json | 4 ++--
tests/index.html | 2 +-
8 files changed, 7 insertions(+), 8 deletions(-)
delete mode 100644 dist/jquery.loadTemplate-1.5.9.min.js
rename dist/{jquery.loadTemplate-1.5.9.js => jquery.loadTemplate.js} (99%)
create mode 100644 dist/jquery.loadTemplate.min.js
diff --git a/Examples/index.html b/Examples/index.html
index 9fe41f0..f14d59a 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/bower.json b/bower.json
index 2e75fef..cbbf747 100644
--- a/bower.json
+++ b/bower.json
@@ -9,7 +9,7 @@
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
},
- "main": "dist/jquery.loadTemplate-1.5.9.js",
+ "main": "dist/jquery.loadTemplate.js",
"keywords": [
"templates",
"templating",
diff --git a/dist/jquery.loadTemplate-1.5.9.min.js b/dist/jquery.loadTemplate-1.5.9.min.js
deleted file mode 100644
index 8488916..0000000
--- a/dist/jquery.loadTemplate-1.5.9.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{async:false,append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){var C=a("
").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/dist/jquery.loadTemplate-1.5.9.js b/dist/jquery.loadTemplate.js
similarity index 99%
rename from dist/jquery.loadTemplate-1.5.9.js
rename to dist/jquery.loadTemplate.js
index 2c272ea..e89c24b 100644
--- a/dist/jquery.loadTemplate-1.5.9.js
+++ b/dist/jquery.loadTemplate.js
@@ -102,7 +102,6 @@
{},
settings,
{
- async: false,
append: !settings.prepend && true,
complete: function (data) {
done++;
diff --git a/dist/jquery.loadTemplate.min.js b/dist/jquery.loadTemplate.min.js
new file mode 100644
index 0000000..c0311fc
--- /dev/null
+++ b/dist/jquery.loadTemplate.min.js
@@ -0,0 +1 @@
+(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){var C=a("
").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a("
");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a("
");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a("
");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
diff --git a/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 0a19894..52192ad 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.5.9",
+ "version": "1.5.10",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/package.json b/package.json
index 4289f28..f8eee4f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "jquery.loadtemplate",
- "version": "1.5.9",
- "main": "dist/jquery.loadTemplate-1.5.9.js",
+ "version": "1.5.10",
+ "main": "dist/jquery.loadTemplate.js",
"author": "Paul Burgess",
"description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
"homepage": "http://codepb.github.io/jquery-template/",
diff --git a/tests/index.html b/tests/index.html
index 1d51108..f0786d9 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 8ab233aab4916bc19a6bc6010c7242d90163a873 Mon Sep 17 00:00:00 2001
From: codepb
Date: Thu, 23 Feb 2017 21:43:36 +0000
Subject: [PATCH 16/20] shorten bower description
---
bower.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bower.json b/bower.json
index cbbf747..5b6e0c6 100644
--- a/bower.json
+++ b/bower.json
@@ -4,7 +4,7 @@
"authors": [
"Paul Burgess "
],
- "description": "jQuery plugin for loading and using templates. The plugin is designed to be simple yet powerful, and supports loading templates from within the page, or using AJAX to load html files.",
+ "description": "jQuery plugin for loading and using templates. The plugin supports loading templates from within the page, or using AJAX to load html files.",
"repository": {
"type": "git",
"url": "https://github.com/codepb/jquery-template.git"
From de4e7460e8d35399ebfed92fc290db8d5624e16c Mon Sep 17 00:00:00 2001
From: LboAnn
Date: Sun, 3 Sep 2017 13:03:36 +0800
Subject: [PATCH 17/20] Add CDNJS version badge in README.md
This badge will show the library version on CDNJS!
---
readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/readme.md b/readme.md
index 7a6d4bd..629ce3a 100644
--- a/readme.md
+++ b/readme.md
@@ -1,4 +1,5 @@
# jQuery.loadTemplate
+[](https://cdnjs.com/libraries/jquery.loadtemplate)
jQuery Template is a jQuery plugin that makes using templates easy and quick. The plugin supports loading HTML files as templates, or taking a jQuery object as the template (usually using script tags to hold the template).
From 1a7ae44d254e0517bf511d2f171f1d6c1ea61c59 Mon Sep 17 00:00:00 2001
From: Juan Pablo Garcia
Date: Tue, 31 Oct 2017 14:22:22 -0400
Subject: [PATCH 18/20] Process data-css attributes
---
dist/jquery.loadTemplate.js | 6 ++++--
dist/jquery.loadTemplate.min.js | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dist/jquery.loadTemplate.js b/dist/jquery.loadTemplate.js
index e89c24b..de8e3d8 100644
--- a/dist/jquery.loadTemplate.js
+++ b/dist/jquery.loadTemplate.js
@@ -323,8 +323,10 @@
$elem.attr("id", applyFormatters($elem, value, "id", settings));
});
-
-
+ processElements("data-css", template, data, settings, function ($elem, value) {
+ $elem.css(applyFormatters($elem, value, "css", settings))
+ });
+
processElements("data-class", template, data, settings, function ($elem, value) {
$elem.addClass(applyFormatters($elem, value, "class", settings));
});
diff --git a/dist/jquery.loadTemplate.min.js b/dist/jquery.loadTemplate.min.js
index c0311fc..c418890 100644
--- a/dist/jquery.loadTemplate.min.js
+++ b/dist/jquery.loadTemplate.min.js
@@ -1 +1 @@
-(function(a){var w={},v={},h={},m;function o(G,C,E){var B=this,A,D,F;C=C||{};F=a.extend(true,{async:true,overwriteCache:false,complete:null,success:null,error:function(){a(this).each(function(){a(this).html(F.errorMessage)})},errorMessage:"There was an error loading the template.",paged:false,pageNo:1,elemPerPage:10,append:false,prepend:false,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:false,ignoreNull:false,ignoreEmptyString:false}},E);if(a.type(C)==="array"){m=true;return t.call(this,G,C,F)}if(!g(G)){A=a(G);if(typeof G==="string"&&G.indexOf("#")===0){F.isFile=false}}D=F.isFile||(typeof F.isFile==="undefined"&&(typeof A==="undefined"||A.length===0));if(D&&!F.overwriteCache&&w[G]){r(G,B,C,F)}else{if(D&&!F.overwriteCache&&w.hasOwnProperty(G)){c(G,B,C,F)}else{if(D){n(G,B,C,F)}else{p(A,B,C,F)}}}return this}function b(B,A){if(A){h[B]=A}else{h=a.extend(h,B)}}function g(A){return typeof A==="string"&&A.indexOf("/")>-1}function t(K,B,H){H=H||{};var A=this,L=B.length,D=H.prepend&&!H.append,C=0,J=0,E=false,F=[],G;if(H.paged){var I=(H.pageNo-1)*H.elemPerPage;B=B.slice(I,I+H.elemPerPage);L=B.length}if(!H.append&&!H.prepend){A.html("")}G=a.extend({},H,{append:!H.prepend&&true,complete:function(M){C++;if(C===L||E){if(E&&H&&typeof H.error==="function"){H.error.call(A,F)}if(H&&typeof H.complete==="function"){H.complete()}}},success:function(){J++;if(J===L){if(H&&typeof H.success==="function"){H.success()}}},error:function(M){E=true;F.push(M)}});if(D){B.reverse()}a(B).each(function(){o.call(A,K,this,G);if(E){return false}});return this}function c(D,B,A,C){if(v[D]){v[D].push({data:A,selection:B,settings:C})}else{v[D]=[{data:A,selection:B,settings:C}]}}function r(E,C,B,D){var A=w[E].clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function x(){return new Date().getTime()}function y(A){if(A.indexOf("?")!==-1){return A+"&_="+x()}else{return A+"?_="+x()}}function n(D,B,A,C){w[D]=null;var E=D;if(C.overwriteCache){E=y(E)}a.ajax({url:E,async:C.async,success:function(F){l(a(F),D,B,A,C)},error:function(F){k(D,B,A,C,F)}})}function p(A,C,B,D){if(A.is("script")||A.is("template")){A=a.parseHTML(a.trim(A.html()))}q.call(C,A,B,D);if(typeof D.success==="function"){D.success()}}function q(C,A,B){var C=a("
").append(C);f(C,A,B);a(this).each(function(){var D=C.children().clone(true);a("select",D).each(function(E,F){a(this).val(a("select",C).eq(E).val())});if(B.beforeInsert){B.beforeInsert(D,A)}if(B.append){a(this).append(D)}else{if(B.prepend){a(this).prepend(D)}else{a(this).html("").append(D)}}if(B.afterInsert){B.afterInsert(D,A)}});if(typeof B.complete==="function"){B.complete.call(a(this),A)}}function k(E,C,A,D,B){var F;if(typeof D.error==="function"){D.error.call(C,B)}a(v[E]).each(function(G,H){if(typeof H.settings.error==="function"){H.settings.error.call(H.selection,B)}});if(typeof D.complete==="function"){D.complete.call(C)}while(v[E]&&(F=v[E].shift())){if(typeof F.settings.complete==="function"){F.settings.complete.call(F.selection)}}if(typeof v[E]!=="undefined"&&v[E].length>0){v[E]=[]}}function l(A,E,C,B,D){var F;w[E]=A.clone();q.call(C,A,B,D);if(typeof D.success==="function"){D.success.call(C)}while(v[E]&&(F=v[E].shift())){q.call(F.selection,w[E].clone(),F.data,F.settings);if(typeof F.settings.success==="function"){F.settings.success.call(F.selection)}}}function f(C,A,B){A=A||{};u("data-content",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-content-append",C,A,B,function(D,E){D.append(e(D,E,"content",B))});u("data-content-prepend",C,A,B,function(D,E){D.prepend(e(D,E,"content",B))});u("data-content-text",C,A,B,function(D,E){D.text(e(D,E,"content",B))});u("data-innerHTML",C,A,B,function(D,E){D.html(e(D,E,"content",B))});u("data-src",C,A,B,function(D,E){D.attr("src",e(D,E,"src",B))},function(D){D.remove()});u("data-href",C,A,B,function(D,E){D.attr("href",e(D,E,"href",B))},function(D){D.remove()});u("data-alt",C,A,B,function(D,E){D.attr("alt",e(D,E,"alt",B))});u("data-id",C,A,B,function(D,E){D.attr("id",e(D,E,"id",B))});u("data-class",C,A,B,function(D,E){D.addClass(e(D,E,"class",B))});u("data-link",C,A,B,function(D,F){var E=a(" ");E.attr("href",e(D,F,"link",B));E.html(D.html());D.html(E)});u("data-link-wrap",C,A,B,function(D,F){var E=a(" ");E.attr("href",e(D,F,"link-wrap",B));D.wrap(E)});u("data-options",C,A,B,function(D,E){a(E).each(function(){var F=a(" ");F.attr("value",this).text(this).appendTo(D)})});s(C,A,B);u("data-value",C,A,B,function(D,E){D.val(e(D,E,"value",B))})}function u(A,F,B,E,C,D){a("["+A+"]",F).each(function(){var G=a(this),H=G.attr(A),I=j(B,H);if(!z(G,I,E)){G.remove();return}G.removeAttr(A);if(typeof I!=="undefined"&&C){C(G,I)}else{if(D){D(G)}}});return}function z(B,D,C){var A=i(B,C);if(A.ignoreUndefined&&typeof D==="undefined"){return false}else{if(A.ignoreNull&&D===null){return false}else{if(A.ignoreEmptyString&&D===""){return false}else{return true}}}}function i(B,C){var A={};if(B instanceof jQuery&&B.attr("data-binding-options")){A=a.parseJSON(B.attr("data-binding-options"));B.removeAttr("data-binding-options")}else{if(typeof B==="object"&&B.hasOwnProperty("bindingOptions")){A=B.bindingOptions}}return a.extend({},C.bindingOptions,A)}function s(C,A,B){a("[data-template-bind]",C).each(function(){var D=a(this),E=a.parseJSON(D.attr("data-template-bind"));D.removeAttr("data-template-bind");a(E).each(function(){var G;if(typeof(this.value)==="object"){G=j(A,this.value.data)}else{G=j(A,this.value)}if(this.attribute){if(!z(this,G,B)){D.remove();return}switch(this.attribute){case"content":case"innerHTML":D.html(d(D,G,this));break;case"contentAppend":D.append(d(D,G,this));break;case"contentPrepend":D.prepend(d(D,G,this));break;case"contentText":D.text(d(D,G,this));break;case"options":var F=this;a(G).each(function(){var H=a(" ");H.attr("value",this[F.value.value]).text(d(D,this[F.value.content],F)).attr("selected",typeof this[F.value.selected]==undefined?false:this[F.value.selected]).appendTo(D)});break;default:D.attr(this.attribute,d(D,G,this))}}})})}function d(A,D,B,C){if(B.formatter&&h[B.formatter]){return(function(E){return h[B.formatter].call(A,D,B.formatOptions,E)})(C)}return D}function j(A,B){if(B==="this"){return A}var C=B.split("."),D,E=A;while((D=C.shift())&&typeof E!=="undefined"&&E!=null){E=E[D]}return E}function e(A,G,B,F){var E=A.attr("data-format-target"),D;if(E===B||(!E&&B==="content")){D=A.attr("data-format");if(D&&typeof h[D]==="function"){var C=A.attr("data-format-options");return(function(H){return h[D].call(A[0],G,C,a.extend({},H))})(F)}}return G}b("nestedTemplateFormatter",function(E,B,A){if(!B){return}if(typeof B==="string"&&B[0]==="{"){B=a.parseJSON(B)}var C=B.parentElement||"div";var D=B.template||B;if(B.parentElement){return a("<"+C+"/>").loadTemplate(D,E,A)}else{return a("<"+C+"/>").loadTemplate(D,E,A).children()}});a.fn.loadTemplate=o;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
+!function(t){"use strict";function e(e,n,c){var s,u,p,d=this;return n=n||{},p=t.extend(!0,{async:!0,overwriteCache:!1,complete:null,success:null,error:function(){t(this).each(function(){t(this).html(p.errorMessage)})},errorMessage:"There was an error loading the template.",paged:!1,pageNo:1,elemPerPage:10,append:!1,prepend:!1,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:!1,ignoreNull:!1,ignoreEmptyString:!1}},c),"array"===t.type(n)?(T=!0,r.call(this,e,n,p)):(a(e)||(s=t(e),"string"==typeof e&&0===e.indexOf("#")&&(p.isFile=!1)),u=p.isFile||"undefined"==typeof p.isFile&&("undefined"==typeof s||0===s.length),u&&!p.overwriteCache&&w[e]?o(e,d,n,p):u&&!p.overwriteCache&&w.hasOwnProperty(e)?i(e,d,n,p):u?l(e,d,n,p):f(s,d,n,p),this)}function n(e,n){n?P[e]=n:P=t.extend(P,e)}function a(t){return"string"==typeof t&&t.indexOf("/")>-1}function r(n,a,r){r=r||{};var i,o=this,c=a.length,s=r.prepend&&!r.append,l=0,f=0,u=!1,p=[];if(r.paged){var d=(r.pageNo-1)*r.elemPerPage;a=a.slice(d,d+r.elemPerPage),c=a.length}return r.append||r.prepend||o.html(""),i=t.extend({},r,{append:!r.prepend&&!0,complete:function(t){l++,(l===c||u)&&(u&&r&&"function"==typeof r.error&&r.error.call(o,p),r&&"function"==typeof r.complete&&r.complete())},success:function(){f++,f===c&&r&&"function"==typeof r.success&&r.success()},error:function(t){u=!0,p.push(t)}}),s&&a.reverse(),t(a).each(function(){return e.call(o,n,this,i),u?!1:void 0}),this}function i(t,e,n,a){k[t]?k[t].push({data:n,selection:e,settings:a}):k[t]=[{data:n,selection:e,settings:a}]}function o(t,e,n,a){var r=w[t].clone();u.call(e,r,n,a),"function"==typeof a.success&&a.success()}function c(){return(new Date).getTime()}function s(t){return-1!==t.indexOf("?")?t+"&_="+c():t+"?_="+c()}function l(e,n,a,r){w[e]=null;var i=e;r.overwriteCache&&(i=s(i)),t.ajax({url:i,async:r.async,success:function(i){d(t(i),e,n,a,r)},error:function(t){p(e,n,a,r,t)}})}function f(e,n,a,r){(e.is("script")||e.is("template"))&&(e=t.parseHTML(t.trim(e.html()))),u.call(n,e,a,r),"function"==typeof r.success&&r.success()}function u(e,n,a){var e=t("
").append(e);h(e,n,a),t(this).each(function(){var r=e.children().clone(!0);t("select",r).each(function(n,a){t(this).val(t("select",e).eq(n).val())}),a.beforeInsert&&a.beforeInsert(r,n),a.append?t(this).append(r):a.prepend?t(this).prepend(r):t(this).html("").append(r),a.afterInsert&&a.afterInsert(r,n)}),"function"==typeof a.complete&&a.complete.call(t(this),n)}function p(e,n,a,r,i){var o;for("function"==typeof r.error&&r.error.call(n,i),t(k[e]).each(function(t,e){"function"==typeof e.settings.error&&e.settings.error.call(e.selection,i)}),"function"==typeof r.complete&&r.complete.call(n);k[e]&&(o=k[e].shift());)"function"==typeof o.settings.complete&&o.settings.complete.call(o.selection);"undefined"!=typeof k[e]&&k[e].length>0&&(k[e]=[])}function d(t,e,n,a,r){var i;for(w[e]=t.clone(),u.call(n,t,a,r),"function"==typeof r.success&&r.success.call(n);k[e]&&(i=k[e].shift());)u.call(i.selection,w[e].clone(),i.data,i.settings),"function"==typeof i.settings.success&&i.settings.success.call(i.selection)}function h(e,n,a){n=n||{},v("data-content",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-content-append",e,n,a,function(t,e){t.append(O(t,e,"content",a))}),v("data-content-prepend",e,n,a,function(t,e){t.prepend(O(t,e,"content",a))}),v("data-content-text",e,n,a,function(t,e){t.text(O(t,e,"content",a))}),v("data-innerHTML",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-src",e,n,a,function(t,e){t.attr("src",O(t,e,"src",a))},function(t){t.remove()}),v("data-href",e,n,a,function(t,e){t.attr("href",O(t,e,"href",a))},function(t){t.remove()}),v("data-alt",e,n,a,function(t,e){t.attr("alt",O(t,e,"alt",a))}),v("data-id",e,n,a,function(t,e){t.attr("id",O(t,e,"id",a))}),v("data-css",e,n,a,function(t,e){t.css(O(t,e,"css",a))}),v("data-class",e,n,a,function(t,e){t.addClass(O(t,e,"class",a))}),v("data-link",e,n,a,function(e,n){var r=t(" ");r.attr("href",O(e,n,"link",a)),r.html(e.html()),e.html(r)}),v("data-link-wrap",e,n,a,function(e,n){var r=t(" ");r.attr("href",O(e,n,"link-wrap",a)),e.wrap(r)}),v("data-options",e,n,a,function(e,n){t(n).each(function(){var n=t(" ");n.attr("value",this).text(this).appendTo(e)})}),y(e,n,a),v("data-value",e,n,a,function(t,e){t.val(O(t,e,"value",a))})}function v(e,n,a,r,i,o){t("["+e+"]",n).each(function(){var n=t(this),c=n.attr(e),s=x(a,c);return m(n,s,r)?(n.removeAttr(e),void("undefined"!=typeof s&&i?i(n,s):o&&o(n))):void n.remove()})}function m(t,e,n){var a=g(t,n);return a.ignoreUndefined&&"undefined"==typeof e?!1:a.ignoreNull&&null===e?!1:a.ignoreEmptyString&&""===e?!1:!0}function g(e,n){var a={};return e instanceof jQuery&&e.attr("data-binding-options")?(a=t.parseJSON(e.attr("data-binding-options")),e.removeAttr("data-binding-options")):"object"==typeof e&&e.hasOwnProperty("bindingOptions")&&(a=e.bindingOptions),t.extend({},n.bindingOptions,a)}function y(e,n,a){t("[data-template-bind]",e).each(function(){var e=t(this),r=t.parseJSON(e.attr("data-template-bind"));e.removeAttr("data-template-bind"),t(r).each(function(){var r;if(r="object"==typeof this.value?x(n,this.value.data):x(n,this.value),this.attribute){if(!m(this,r,a))return void e.remove();switch(this.attribute){case"content":case"innerHTML":e.html(b(e,r,this));break;case"contentAppend":e.append(b(e,r,this));break;case"contentPrepend":e.prepend(b(e,r,this));break;case"contentText":e.text(b(e,r,this));break;case"options":var i=this;t(r).each(function(){var n=t(" ");n.attr("value",this[i.value.value]).text(b(e,this[i.value.content],i)).attr("selected",void 0==typeof this[i.value.selected]?!1:this[i.value.selected]).appendTo(e)});break;default:e.attr(this.attribute,b(e,r,this))}}})})}function b(t,e,n,a){return n.formatter&&P[n.formatter]?function(a){return P[n.formatter].call(t,e,n.formatOptions,a)}(a):e}function x(t,e){if("this"===e)return t;for(var n,a=e.split("."),r=t;(n=a.shift())&&"undefined"!=typeof r&&null!=r;)r=r[n];return r}function O(e,n,a,r){var i,o=e.attr("data-format-target");if((o===a||!o&&"content"===a)&&(i=e.attr("data-format"),i&&"function"==typeof P[i])){var c=e.attr("data-format-options");return function(a){return P[i].call(e[0],n,c,t.extend({},a))}(r)}return n}var T,w={},k={},P={};n("nestedTemplateFormatter",function(e,n,a){if(n){"string"==typeof n&&"{"===n[0]&&(n=t.parseJSON(n));var r=n.parentElement||"div",i=n.template||n;return n.parentElement?t("<"+r+"/>").loadTemplate(i,e,a):t("<"+r+"/>").loadTemplate(i,e,a).children()}}),t.fn.loadTemplate=e,t.addTemplateFormatter=n}(jQuery);
\ No newline at end of file
From 609d18a74760dae79efb49364bfdf4d62ed520c3 Mon Sep 17 00:00:00 2001
From: Juan Pablo Garcia
Date: Tue, 31 Oct 2017 17:34:56 -0400
Subject: [PATCH 19/20] Readme fixed.
---
readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/readme.md b/readme.md
index 629ce3a..3b0970f 100644
--- a/readme.md
+++ b/readme.md
@@ -110,6 +110,7 @@ There are a number of different bindings and ways to bind the data. The followin
- "data-alt" - sets the alt value of the element to the value provided (uses $(elem).attr("alt", value));
- "data-value" - sets the value attribute of the element to the value provided (uses $(elem).val(value))
- "data-class" - sets the class attribute of the element to the value provided (uses $(elem).class(value))
+- "data-css" - sets the CSS attribute of the element to the value provided (uses $(elem).css(value))
- "data-link" - sets the innerHtml of the element to be a link to the value provided (wraps the content in an <a> tag).
- "data-link-wrap" - wraps the element in a link to the value provided. Same as "data-link", but the <a> tag wraps the element as well as the content.
- "data-options" - adds options to a select box. The value for this should reference an array of strings, each option will be output as a separate option. The value will be the same as the displayed text for each option. For a more powerful version of this look at the data-template-bind option.
From a55f164e1b60c6d52a5e4affe0408f9797d88c6d Mon Sep 17 00:00:00 2001
From: Luciano Bustos
Date: Mon, 8 Jan 2018 14:55:52 -0300
Subject: [PATCH 20/20] Adding title attribute support.
---
dist/jquery.loadTemplate.js | 4 ++++
dist/jquery.loadTemplate.min.js | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dist/jquery.loadTemplate.js b/dist/jquery.loadTemplate.js
index de8e3d8..aa9ba52 100644
--- a/dist/jquery.loadTemplate.js
+++ b/dist/jquery.loadTemplate.js
@@ -318,6 +318,10 @@
processElements("data-alt", template, data, settings, function ($elem, value) {
$elem.attr("alt", applyFormatters($elem, value, "alt", settings));
});
+
+ processElements("data-title", template, data, settings, function ($elem, value) {
+ $elem.attr("title", applyFormatters($elem, value, "title", settings));
+ });
processElements("data-id", template, data, settings, function ($elem, value) {
$elem.attr("id", applyFormatters($elem, value, "id", settings));
diff --git a/dist/jquery.loadTemplate.min.js b/dist/jquery.loadTemplate.min.js
index c418890..bf88099 100644
--- a/dist/jquery.loadTemplate.min.js
+++ b/dist/jquery.loadTemplate.min.js
@@ -1 +1 @@
-!function(t){"use strict";function e(e,n,c){var s,u,p,d=this;return n=n||{},p=t.extend(!0,{async:!0,overwriteCache:!1,complete:null,success:null,error:function(){t(this).each(function(){t(this).html(p.errorMessage)})},errorMessage:"There was an error loading the template.",paged:!1,pageNo:1,elemPerPage:10,append:!1,prepend:!1,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:!1,ignoreNull:!1,ignoreEmptyString:!1}},c),"array"===t.type(n)?(T=!0,r.call(this,e,n,p)):(a(e)||(s=t(e),"string"==typeof e&&0===e.indexOf("#")&&(p.isFile=!1)),u=p.isFile||"undefined"==typeof p.isFile&&("undefined"==typeof s||0===s.length),u&&!p.overwriteCache&&w[e]?o(e,d,n,p):u&&!p.overwriteCache&&w.hasOwnProperty(e)?i(e,d,n,p):u?l(e,d,n,p):f(s,d,n,p),this)}function n(e,n){n?P[e]=n:P=t.extend(P,e)}function a(t){return"string"==typeof t&&t.indexOf("/")>-1}function r(n,a,r){r=r||{};var i,o=this,c=a.length,s=r.prepend&&!r.append,l=0,f=0,u=!1,p=[];if(r.paged){var d=(r.pageNo-1)*r.elemPerPage;a=a.slice(d,d+r.elemPerPage),c=a.length}return r.append||r.prepend||o.html(""),i=t.extend({},r,{append:!r.prepend&&!0,complete:function(t){l++,(l===c||u)&&(u&&r&&"function"==typeof r.error&&r.error.call(o,p),r&&"function"==typeof r.complete&&r.complete())},success:function(){f++,f===c&&r&&"function"==typeof r.success&&r.success()},error:function(t){u=!0,p.push(t)}}),s&&a.reverse(),t(a).each(function(){return e.call(o,n,this,i),u?!1:void 0}),this}function i(t,e,n,a){k[t]?k[t].push({data:n,selection:e,settings:a}):k[t]=[{data:n,selection:e,settings:a}]}function o(t,e,n,a){var r=w[t].clone();u.call(e,r,n,a),"function"==typeof a.success&&a.success()}function c(){return(new Date).getTime()}function s(t){return-1!==t.indexOf("?")?t+"&_="+c():t+"?_="+c()}function l(e,n,a,r){w[e]=null;var i=e;r.overwriteCache&&(i=s(i)),t.ajax({url:i,async:r.async,success:function(i){d(t(i),e,n,a,r)},error:function(t){p(e,n,a,r,t)}})}function f(e,n,a,r){(e.is("script")||e.is("template"))&&(e=t.parseHTML(t.trim(e.html()))),u.call(n,e,a,r),"function"==typeof r.success&&r.success()}function u(e,n,a){var e=t("
").append(e);h(e,n,a),t(this).each(function(){var r=e.children().clone(!0);t("select",r).each(function(n,a){t(this).val(t("select",e).eq(n).val())}),a.beforeInsert&&a.beforeInsert(r,n),a.append?t(this).append(r):a.prepend?t(this).prepend(r):t(this).html("").append(r),a.afterInsert&&a.afterInsert(r,n)}),"function"==typeof a.complete&&a.complete.call(t(this),n)}function p(e,n,a,r,i){var o;for("function"==typeof r.error&&r.error.call(n,i),t(k[e]).each(function(t,e){"function"==typeof e.settings.error&&e.settings.error.call(e.selection,i)}),"function"==typeof r.complete&&r.complete.call(n);k[e]&&(o=k[e].shift());)"function"==typeof o.settings.complete&&o.settings.complete.call(o.selection);"undefined"!=typeof k[e]&&k[e].length>0&&(k[e]=[])}function d(t,e,n,a,r){var i;for(w[e]=t.clone(),u.call(n,t,a,r),"function"==typeof r.success&&r.success.call(n);k[e]&&(i=k[e].shift());)u.call(i.selection,w[e].clone(),i.data,i.settings),"function"==typeof i.settings.success&&i.settings.success.call(i.selection)}function h(e,n,a){n=n||{},v("data-content",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-content-append",e,n,a,function(t,e){t.append(O(t,e,"content",a))}),v("data-content-prepend",e,n,a,function(t,e){t.prepend(O(t,e,"content",a))}),v("data-content-text",e,n,a,function(t,e){t.text(O(t,e,"content",a))}),v("data-innerHTML",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-src",e,n,a,function(t,e){t.attr("src",O(t,e,"src",a))},function(t){t.remove()}),v("data-href",e,n,a,function(t,e){t.attr("href",O(t,e,"href",a))},function(t){t.remove()}),v("data-alt",e,n,a,function(t,e){t.attr("alt",O(t,e,"alt",a))}),v("data-id",e,n,a,function(t,e){t.attr("id",O(t,e,"id",a))}),v("data-css",e,n,a,function(t,e){t.css(O(t,e,"css",a))}),v("data-class",e,n,a,function(t,e){t.addClass(O(t,e,"class",a))}),v("data-link",e,n,a,function(e,n){var r=t(" ");r.attr("href",O(e,n,"link",a)),r.html(e.html()),e.html(r)}),v("data-link-wrap",e,n,a,function(e,n){var r=t(" ");r.attr("href",O(e,n,"link-wrap",a)),e.wrap(r)}),v("data-options",e,n,a,function(e,n){t(n).each(function(){var n=t(" ");n.attr("value",this).text(this).appendTo(e)})}),y(e,n,a),v("data-value",e,n,a,function(t,e){t.val(O(t,e,"value",a))})}function v(e,n,a,r,i,o){t("["+e+"]",n).each(function(){var n=t(this),c=n.attr(e),s=x(a,c);return m(n,s,r)?(n.removeAttr(e),void("undefined"!=typeof s&&i?i(n,s):o&&o(n))):void n.remove()})}function m(t,e,n){var a=g(t,n);return a.ignoreUndefined&&"undefined"==typeof e?!1:a.ignoreNull&&null===e?!1:a.ignoreEmptyString&&""===e?!1:!0}function g(e,n){var a={};return e instanceof jQuery&&e.attr("data-binding-options")?(a=t.parseJSON(e.attr("data-binding-options")),e.removeAttr("data-binding-options")):"object"==typeof e&&e.hasOwnProperty("bindingOptions")&&(a=e.bindingOptions),t.extend({},n.bindingOptions,a)}function y(e,n,a){t("[data-template-bind]",e).each(function(){var e=t(this),r=t.parseJSON(e.attr("data-template-bind"));e.removeAttr("data-template-bind"),t(r).each(function(){var r;if(r="object"==typeof this.value?x(n,this.value.data):x(n,this.value),this.attribute){if(!m(this,r,a))return void e.remove();switch(this.attribute){case"content":case"innerHTML":e.html(b(e,r,this));break;case"contentAppend":e.append(b(e,r,this));break;case"contentPrepend":e.prepend(b(e,r,this));break;case"contentText":e.text(b(e,r,this));break;case"options":var i=this;t(r).each(function(){var n=t(" ");n.attr("value",this[i.value.value]).text(b(e,this[i.value.content],i)).attr("selected",void 0==typeof this[i.value.selected]?!1:this[i.value.selected]).appendTo(e)});break;default:e.attr(this.attribute,b(e,r,this))}}})})}function b(t,e,n,a){return n.formatter&&P[n.formatter]?function(a){return P[n.formatter].call(t,e,n.formatOptions,a)}(a):e}function x(t,e){if("this"===e)return t;for(var n,a=e.split("."),r=t;(n=a.shift())&&"undefined"!=typeof r&&null!=r;)r=r[n];return r}function O(e,n,a,r){var i,o=e.attr("data-format-target");if((o===a||!o&&"content"===a)&&(i=e.attr("data-format"),i&&"function"==typeof P[i])){var c=e.attr("data-format-options");return function(a){return P[i].call(e[0],n,c,t.extend({},a))}(r)}return n}var T,w={},k={},P={};n("nestedTemplateFormatter",function(e,n,a){if(n){"string"==typeof n&&"{"===n[0]&&(n=t.parseJSON(n));var r=n.parentElement||"div",i=n.template||n;return n.parentElement?t("<"+r+"/>").loadTemplate(i,e,a):t("<"+r+"/>").loadTemplate(i,e,a).children()}}),t.fn.loadTemplate=e,t.addTemplateFormatter=n}(jQuery);
\ No newline at end of file
+!function(t){"use strict";function e(e,n,c){var s,f,p,d=this;return n=n||{},p=t.extend(!0,{async:!0,overwriteCache:!1,complete:null,success:null,error:function(){t(this).each(function(){t(this).html(p.errorMessage)})},errorMessage:"There was an error loading the template.",paged:!1,pageNo:1,elemPerPage:10,append:!1,prepend:!1,beforeInsert:null,afterInsert:null,bindingOptions:{ignoreUndefined:!1,ignoreNull:!1,ignoreEmptyString:!1}},c),"array"===t.type(n)?(T=!0,i.call(this,e,n,p)):(a(e)||(s=t(e),"string"==typeof e&&0===e.indexOf("#")&&(p.isFile=!1)),f=p.isFile||void 0===p.isFile&&(void 0===s||0===s.length),f&&!p.overwriteCache&&w[e]?o(e,d,n,p):f&&!p.overwriteCache&&w.hasOwnProperty(e)?r(e,d,n,p):f?l(e,d,n,p):u(s,d,n,p),this)}function n(e,n){n?P[e]=n:P=t.extend(P,e)}function a(t){return"string"==typeof t&&t.indexOf("/")>-1}function i(n,a,i){i=i||{};var r,o=this,c=a.length,s=i.prepend&&!i.append,l=0,u=0,f=!1,p=[];if(i.paged){var d=(i.pageNo-1)*i.elemPerPage;a=a.slice(d,d+i.elemPerPage),c=a.length}return i.append||i.prepend||o.html(""),r=t.extend({},i,{append:!i.prepend&&!0,complete:function(t){(++l===c||f)&&(f&&i&&"function"==typeof i.error&&i.error.call(o,p),i&&"function"==typeof i.complete&&i.complete())},success:function(){++u===c&&i&&"function"==typeof i.success&&i.success()},error:function(t){f=!0,p.push(t)}}),s&&a.reverse(),t(a).each(function(){if(e.call(o,n,this,r),f)return!1}),this}function r(t,e,n,a){k[t]?k[t].push({data:n,selection:e,settings:a}):k[t]=[{data:n,selection:e,settings:a}]}function o(t,e,n,a){var i=w[t].clone();f.call(e,i,n,a),"function"==typeof a.success&&a.success()}function c(){return(new Date).getTime()}function s(t){return-1!==t.indexOf("?")?t+"&_="+c():t+"?_="+c()}function l(e,n,a,i){w[e]=null;var r=e;i.overwriteCache&&(r=s(r)),t.ajax({url:r,async:i.async,success:function(r){d(t(r),e,n,a,i)},error:function(t){p(e,n,a,i,t)}})}function u(e,n,a,i){(e.is("script")||e.is("template"))&&(e=t.parseHTML(t.trim(e.html()))),f.call(n,e,a,i),"function"==typeof i.success&&i.success()}function f(e,n,a){h(e=t("
").append(e),n,a),t(this).each(function(){var i=e.children().clone(!0);t("select",i).each(function(n,a){t(this).val(t("select",e).eq(n).val())}),a.beforeInsert&&a.beforeInsert(i,n),a.append?t(this).append(i):a.prepend?t(this).prepend(i):t(this).html("").append(i),a.afterInsert&&a.afterInsert(i,n)}),"function"==typeof a.complete&&a.complete.call(t(this),n)}function p(e,n,a,i,r){var o;for("function"==typeof i.error&&i.error.call(n,r),t(k[e]).each(function(t,e){"function"==typeof e.settings.error&&e.settings.error.call(e.selection,r)}),"function"==typeof i.complete&&i.complete.call(n);k[e]&&(o=k[e].shift());)"function"==typeof o.settings.complete&&o.settings.complete.call(o.selection);void 0!==k[e]&&k[e].length>0&&(k[e]=[])}function d(t,e,n,a,i){var r;for(w[e]=t.clone(),f.call(n,t,a,i),"function"==typeof i.success&&i.success.call(n);k[e]&&(r=k[e].shift());)f.call(r.selection,w[e].clone(),r.data,r.settings),"function"==typeof r.settings.success&&r.settings.success.call(r.selection)}function h(e,n,a){v("data-content",e,n=n||{},a,function(t,e){t.html(O(t,e,"content",a))}),v("data-content-append",e,n,a,function(t,e){t.append(O(t,e,"content",a))}),v("data-content-prepend",e,n,a,function(t,e){t.prepend(O(t,e,"content",a))}),v("data-content-text",e,n,a,function(t,e){t.text(O(t,e,"content",a))}),v("data-innerHTML",e,n,a,function(t,e){t.html(O(t,e,"content",a))}),v("data-src",e,n,a,function(t,e){t.attr("src",O(t,e,"src",a))},function(t){t.remove()}),v("data-href",e,n,a,function(t,e){t.attr("href",O(t,e,"href",a))},function(t){t.remove()}),v("data-alt",e,n,a,function(t,e){t.attr("alt",O(t,e,"alt",a))}),v("data-title",e,n,a,function(t,e){t.attr("title",O(t,e,"title",a))}),v("data-id",e,n,a,function(t,e){t.attr("id",O(t,e,"id",a))}),v("data-css",e,n,a,function(t,e){t.css(O(t,e,"css",a))}),v("data-class",e,n,a,function(t,e){t.addClass(O(t,e,"class",a))}),v("data-link",e,n,a,function(e,n){var i=t(" ");i.attr("href",O(e,n,"link",a)),i.html(e.html()),e.html(i)}),v("data-link-wrap",e,n,a,function(e,n){var i=t(" ");i.attr("href",O(e,n,"link-wrap",a)),e.wrap(i)}),v("data-options",e,n,a,function(e,n){t(n).each(function(){t(" ").attr("value",this).text(this).appendTo(e)})}),y(e,n,a),v("data-value",e,n,a,function(t,e){t.val(O(t,e,"value",a))})}function v(e,n,a,i,r,o){t("["+e+"]",n).each(function(){var n=t(this),c=n.attr(e),s=x(a,c);m(n,s,i)?(n.removeAttr(e),void 0!==s&&r?r(n,s):o&&o(n)):n.remove()})}function m(t,e,n){var a=g(t,n);return(!a.ignoreUndefined||void 0!==e)&&((!a.ignoreNull||null!==e)&&(!a.ignoreEmptyString||""!==e))}function g(e,n){var a={};return e instanceof jQuery&&e.attr("data-binding-options")?(a=t.parseJSON(e.attr("data-binding-options")),e.removeAttr("data-binding-options")):"object"==typeof e&&e.hasOwnProperty("bindingOptions")&&(a=e.bindingOptions),t.extend({},n.bindingOptions,a)}function y(e,n,a){t("[data-template-bind]",e).each(function(){var e=t(this),i=t.parseJSON(e.attr("data-template-bind"));e.removeAttr("data-template-bind"),t(i).each(function(){var i;if(i="object"==typeof this.value?x(n,this.value.data):x(n,this.value),this.attribute){if(!m(this,i,a))return void e.remove();switch(this.attribute){case"content":case"innerHTML":e.html(b(e,i,this));break;case"contentAppend":e.append(b(e,i,this));break;case"contentPrepend":e.prepend(b(e,i,this));break;case"contentText":e.text(b(e,i,this));break;case"options":var r=this;t(i).each(function(){t(" ").attr("value",this[r.value.value]).text(b(e,this[r.value.content],r)).attr("selected",void 0!=typeof this[r.value.selected]&&this[r.value.selected]).appendTo(e)});break;default:e.attr(this.attribute,b(e,i,this))}}})})}function b(t,e,n,a){return n.formatter&&P[n.formatter]?function(a){return P[n.formatter].call(t,e,n.formatOptions,a)}(a):e}function x(t,e){if("this"===e)return t;for(var n,a=e.split("."),i=t;(n=a.shift())&&void 0!==i&&null!=i;)i=i[n];return i}function O(e,n,a,i){var r,o=e.attr("data-format-target");if((o===a||!o&&"content"===a)&&(r=e.attr("data-format"))&&"function"==typeof P[r]){var c=e.attr("data-format-options");return function(a){return P[r].call(e[0],n,c,t.extend({},a))}(i)}return n}var T,w={},k={},P={};n("nestedTemplateFormatter",function(e,n,a){if(n){"string"==typeof n&&"{"===n[0]&&(n=t.parseJSON(n));var i=n.parentElement||"div",r=n.template||n;return n.parentElement?t("<"+i+"/>").loadTemplate(r,e,a):t("<"+i+"/>").loadTemplate(r,e,a).children()}}),t.fn.loadTemplate=e,t.addTemplateFormatter=n}(jQuery);
\ No newline at end of file