From 1823add2ff5bfa27b307cb42e895932484be4e95 Mon Sep 17 00:00:00 2001
From: Chris Rogers
Date: Tue, 6 May 2014 10:00:52 -0500
Subject: [PATCH 01/34] Updates to jquery.loadTemplate-1.4.3.js
As per my two issue submissions:
1) Modified getValue to accommodate null values during data binding
2) Modified the nestedTemplateFormatter to only return the generated child nodes if the parentElement is not specified.
---
jquery-loadTemplate/jquery.loadTemplate-1.4.3.js | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
index 52c43a0..b80b10e 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
@@ -471,7 +471,7 @@
part,
value = data;
- while ((part = paramParts.shift()) && typeof value !== "undefined") {
+ while ((part = paramParts.shift()) && typeof value !== "undefined" && value != null) {
value = value[part];
}
@@ -505,7 +505,12 @@
var parentElement = options.parentElement || "div";
var template = options.template || options;
- return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings);
+
+ //If a parent is specified, return it; otherwise only return the generated children.
+ if(options.parentElement)
+ return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings);
+ else
+ return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings).children();
});
$.fn.loadTemplate = loadTemplate;
$.addTemplateFormatter = addTemplateFormatter;
From 55407d3f7c65a7b086efd474f420d6a1d55b851a Mon Sep 17 00:00:00 2001
From: Adis
Date: Wed, 14 May 2014 00:44:26 +0600
Subject: [PATCH 02/34] Added data-href binding
Added data-href binding
---
jquery-loadTemplate/jquery.loadTemplate-1.4.3.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
index 52c43a0..e2f60d9 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
@@ -305,6 +305,12 @@
}, function ($elem) {
$elem.remove();
});
+
+ processElements("data-href", template, data, settings, function ($elem, value) {
+ $elem.attr("href", applyFormatters($elem, value, "href", settings));
+ }, function ($elem) {
+ $elem.remove();
+ });
processElements("data-alt", template, data, settings, function ($elem, value) {
$elem.attr("alt", applyFormatters($elem, value, "alt", settings));
From 6964c08ba63eb49ce8d366fa4073a444cd5fb32d Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Sun, 18 May 2014 13:40:50 +0100
Subject: [PATCH 03/34] Updated documentation, and version
---
Examples/index.html | 2 +-
...query.loadTemplate-1.4.3.js => jquery.loadTemplate-1.4.4.js} | 0
...adTemplate-1.4.3.min.js => jquery.loadTemplate-1.4.4.min.js} | 2 +-
loadTemplate.jquery.json | 2 +-
readme.md | 1 +
tests/index.html | 2 +-
6 files changed, 5 insertions(+), 4 deletions(-)
rename jquery-loadTemplate/{jquery.loadTemplate-1.4.3.js => jquery.loadTemplate-1.4.4.js} (100%)
rename jquery-loadTemplate/{jquery.loadTemplate-1.4.3.min.js => jquery.loadTemplate-1.4.4.min.js} (54%)
diff --git a/Examples/index.html b/Examples/index.html
index 6a4bc64..ad2f922 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -9,7 +9,7 @@
-
+
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.4.js
similarity index 100%
rename from jquery-loadTemplate/jquery.loadTemplate-1.4.3.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.4.4.js
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js
similarity index 54%
rename from jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js
index c162670..b21b477 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.3.min.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js
@@ -1 +1 @@
-(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(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("");n.call(K,I,this,E);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(){k(D,B,A,C)}})}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)}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)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}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-src",B,z,A,function(C,D){C.attr("src",e(C,D,"src",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-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":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=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;return a("<"+B+"/>").loadTemplate(C,D,z)});a.fn.loadTemplate=n;a.addTemplateFormatter=b})(jQuery);
\ No newline at end of file
+(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(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("");n.call(K,I,this,E);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(){k(D,B,A,C)}})}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)}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)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}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-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-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":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/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 837eda8..1f52deb 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.4.3",
+ "version": "1.4.4",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/readme.md b/readme.md
index 1efda54..34ba5b7 100644
--- a/readme.md
+++ b/readme.md
@@ -99,6 +99,7 @@ There are a number of different bindings and ways to bind the data. The followin
- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value))
- "data-content-prepend" - prepends the value to the beginning of the element (uses $(elem).prepend(value))
- "data-id" - sets the id of the element to the value provided (uses $(elem).attr("id", value));
+- "data-href" - sets the href value of the element to the value provided (uses $(elem).attr("href", value));
- "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-link" - sets the innerHtml of the element to be a link to the value provided (wraps the content in an <a> tag).
diff --git a/tests/index.html b/tests/index.html
index 3b28627..3b986d9 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From cf7c6558b0b325cfa5876d6c855fc8d717ba6c0e Mon Sep 17 00:00:00 2001
From: codepb
Date: Sat, 26 Jul 2014 22:06:19 +0100
Subject: [PATCH 04/34] Update readme.md
Added the data-content-text documentation
---
readme.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index 34ba5b7..fc2c9b4 100644
--- a/readme.md
+++ b/readme.md
@@ -96,6 +96,7 @@ Formatters must be added before they are used else a template will not be able t
There are a number of different bindings and ways to bind the data. The following attributes are available:
- "data-content" - binds the value supplied to the content of the element (uses $(elem).html(value))
+- "data-content-text" - binds the value supplied to the content of the element as text (uses $(elem).text(value))
- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value))
- "data-content-prepend" - prepends the value to the beginning of the element (uses $(elem).prepend(value))
- "data-id" - sets the id of the element to the value provided (uses $(elem).attr("id", value));
@@ -143,4 +144,4 @@ There are a number of options the plugin accepts. These are:
## Future Plans
-I would like to develop the plugin further so it would be possible to watch the objects holding the data, so any changes to the data would be reflected in the UI. This would have to be simple, lightweight, and ideally would work just with natural JavaScript objects. I also welcome any ideas as to how the plugin could be improved.
\ No newline at end of file
+I would like to develop the plugin further so it would be possible to watch the objects holding the data, so any changes to the data would be reflected in the UI. This would have to be simple, lightweight, and ideally would work just with natural JavaScript objects. I also welcome any ideas as to how the plugin could be improved.
From df4778525df5e8968ab55d885ad54af6ceab911d Mon Sep 17 00:00:00 2001
From: codepb
Date: Thu, 21 Aug 2014 16:38:48 +0100
Subject: [PATCH 05/34] Update readme.md
Showed how to use options in the plugin
---
readme.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index fc2c9b4..0b74f72 100644
--- a/readme.md
+++ b/readme.md
@@ -125,7 +125,11 @@ An example of using the "data-template-bind" attribute would be the following:
### Options
-There are a number of options the plugin accepts. These are:
+There are a number of options the plugin accepts. These can be set by passing an object containing the settings you would like to set as the third parameter to .loadTemplate:
+
+ $(container).loadTemplate(template, data, { append: true, elemPerPage: 20 });
+
+The full list of options are:
- "overwriteCache" (default false) - Whether to ignore the cache and reload the template (if you've previously loaded the template, but it might have changed, you'll want to set this to true.
- "complete" (default null) - Callback function to call on complete. Will always be called regardless of success or failure.
From 6394a1fb2e845225fdcaa4d46c4bc01a5875b055 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Wed, 22 Oct 2014 11:01:22 +0100
Subject: [PATCH 06/34] Added data-class and data-innerHTML
data-innerHTML is the new name for data-content to prepare for version
2. data-content is maintained for legacy support, but the plan is to
remove this in version 2. data-template-bind will also accept
"innerHTML" as a replacement to content. Again the plan is to free up
content, as this could be a valid attribute of some elements. data-class
will bind to the class attribute
---
Examples/SimpleExample/Templates/simple.html | 2 +-
Examples/SimpleExample/example.html | 2 +-
Examples/index.html | 2 +-
...oadTemplate-1.4.4.js => jquery.loadTemplate-1.4.5.js} | 9 +++++++++
...ate-1.4.4.min.js => jquery.loadTemplate-1.4.5.min.js} | 2 +-
loadTemplate.jquery.json | 2 +-
readme.md | 4 +++-
tests/index.html | 2 +-
8 files changed, 18 insertions(+), 7 deletions(-)
rename jquery-loadTemplate/{jquery.loadTemplate-1.4.4.js => jquery.loadTemplate-1.4.5.js} (97%)
rename jquery-loadTemplate/{jquery.loadTemplate-1.4.4.min.js => jquery.loadTemplate-1.4.5.min.js} (52%)
diff --git a/Examples/SimpleExample/Templates/simple.html b/Examples/SimpleExample/Templates/simple.html
index dc613aa..c844792 100644
--- a/Examples/SimpleExample/Templates/simple.html
+++ b/Examples/SimpleExample/Templates/simple.html
@@ -5,7 +5,7 @@
Example of loading a template from a script tag within the same document.
-
+
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.js
similarity index 97%
rename from jquery-loadTemplate/jquery.loadTemplate-1.4.4.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.4.5.js
index b678cd8..46275a8 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.js
@@ -300,6 +300,10 @@
$elem.text(applyFormatters($elem, value, "content", settings));
});
+ processElements("data-innerHTML", template, data, settings, function ($elem, value) {
+ $elem.html(applyFormatters($elem, value, "content", settings));
+ });
+
processElements("data-src", template, data, settings, function ($elem, value) {
$elem.attr("src", applyFormatters($elem, value, "src", settings));
}, function ($elem) {
@@ -324,6 +328,10 @@
$elem.attr("value", applyFormatters($elem, value, "value", settings));
});
+ processElements("data-class", template, data, settings, function ($elem, value) {
+ $elem.addClass(applyFormatters($elem, value, "class", settings));
+ });
+
processElements("data-link", template, data, settings, function ($elem, value) {
var $linkElem = $("");
$linkElem.attr("href", applyFormatters($elem, value, "link", settings));
@@ -430,6 +438,7 @@
switch (this.attribute) {
case "content":
+ case "innerHTML":
$this.html(applyDataBindFormatters($this, value, this));
break;
case "contentAppend":
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js
similarity index 52%
rename from jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js
index b21b477..64dab52 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.4.min.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js
@@ -1 +1 @@
-(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(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("");n.call(K,I,this,E);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(){k(D,B,A,C)}})}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)}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)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}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-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-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":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
+(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(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("");n.call(K,I,this,E);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(){k(D,B,A,C)}})}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)}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)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}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/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 1f52deb..3ff9610 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.4.4",
+ "version": "1.4.5",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/readme.md b/readme.md
index 0b74f72..5267759 100644
--- a/readme.md
+++ b/readme.md
@@ -95,7 +95,8 @@ Formatters must be added before they are used else a template will not be able t
### Bindings
There are a number of different bindings and ways to bind the data. The following attributes are available:
-- "data-content" - binds the value supplied to the content of the element (uses $(elem).html(value))
+- "data-innerHTML" (<= 1.4.5) - binds the value supplied to the content (innerHTML) of the element (uses $(elem).html(value))
+- "data-content" - alias for the newer "data-innerHTML"
- "data-content-text" - binds the value supplied to the content of the element as text (uses $(elem).text(value))
- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value))
- "data-content-prepend" - prepends the value to the beginning of the element (uses $(elem).prepend(value))
@@ -103,6 +104,7 @@ There are a number of different bindings and ways to bind the data. The followin
- "data-href" - sets the href value of the element to the value provided (uses $(elem).attr("href", value));
- "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-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.
diff --git a/tests/index.html b/tests/index.html
index 3b986d9..e1d7e36 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 2ff396cd0cd838506f235e0678bef662cf98819c Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Wed, 22 Oct 2014 11:47:50 +0100
Subject: [PATCH 07/34] adding npm package.json file
---
Package.json | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Package.json
diff --git a/Package.json b/Package.json
new file mode 100644
index 0000000..84b6879
--- /dev/null
+++ b/Package.json
@@ -0,0 +1,21 @@
+{
+ "name": "jquery.loadtemplate",
+ "version": "1.4.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/",
+ "keywords": [
+ "templates",
+ "templating",
+ "jquery-plugin"
+ ],
+ "bugs": "https://github.com/codepb/jquery-template/issues",
+ "license": "MIT",
+ "repository" : {
+ "type" : "git",
+ "url" : "https://github.com/codepb/jquery-template"
+ },
+ "dependencies" : {
+ "jquery": ">=1.8"
+ }
+}
From bc9632a97160b6a330da14b530c50d91c4596705 Mon Sep 17 00:00:00 2001
From: Vladimir Kalyuzhny
Date: Mon, 16 Feb 2015 10:16:17 +0200
Subject: [PATCH 08/34] Package.json -> package.json
npm http GET https://registry.npmjs.org/jquery.loadtemplate
npm http 304 https://registry.npmjs.org/jquery.loadtemplate
npm http GET https://registry.npmjs.org/jquery.loadtemplate/-/jquery.loadtemplate-1.4.5.tgz
npm http 200 https://registry.npmjs.org/jquery.loadtemplate/-/jquery.loadtemplate-1.4.5.tgz
npm ERR! Error: ENOENT, open '/home/user/tmp/npm-3110-yhl7Nl4j/1424074130295-0.633399919141084/package/package.json'
npm ERR! If you need help, you may report this log at:
npm ERR!
npm ERR! or email it to:
npm ERR!
package.json should be named in lower case.
---
Package.json => package.json | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Package.json => package.json (100%)
diff --git a/Package.json b/package.json
similarity index 100%
rename from Package.json
rename to package.json
From bfa83fee4ab7ba78144a02ecf74aa38038866f49 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Sun, 1 Mar 2015 21:32:03 +0000
Subject: [PATCH 09/34] Adding bower.json
---
bower.json | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 bower.json
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..01af15b
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,34 @@
+{
+ "name": "jquery-load-template",
+ "version": "1.4.5",
+ "authors": [
+ { "name": "Paul Burgess"}
+ ],
+ "homepage": "http://codepb.github.io/jquery-template/",
+ "repository": {
+ "type": "git",
+ "url": "git://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",
+ ".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"
+ },
+}
From 5011b0dcc2c35a0213e0a15a2143d890d00e012a Mon Sep 17 00:00:00 2001
From: codepb
Date: Tue, 2 Jun 2015 08:59:10 +0100
Subject: [PATCH 10/34] Update readme.md to include documentation on async
---
readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/readme.md b/readme.md
index 5267759..7ed4472 100644
--- a/readme.md
+++ b/readme.md
@@ -134,6 +134,7 @@ There are a number of options the plugin accepts. These can be set by passing an
The full list of options are:
- "overwriteCache" (default false) - Whether to ignore the cache and reload the template (if you've previously loaded the template, but it might have changed, you'll want to set this to true.
+- "async" (default true) - Whether to load templates asynchronously (if templates require an Ajax call)
- "complete" (default null) - Callback function to call on complete. Will always be called regardless of success or failure.
- "success" (default null) - Callback function to call on successful completion.
- "error" (default, outputting error message to template container) - Callback function to call on error.
From 312cc023d312081430c79ce63f26a59be39fcb63 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Thu, 3 Sep 2015 15:38:31 +0100
Subject: [PATCH 11/34] beforeInsert/afterInsert callbacks and error info
additions
Added the data to beforeInsert and afterInsert callbacks: fixes #69.
Updated the error callback to add in the error coming from the ajax
call. fixes #67.
---
Examples/SimpleExample/example.html | 2 +-
Examples/index.html | 2 +-
bower.json | 2 +-
.../jquery.loadTemplate-1.4.5.min.js | 1 -
...-1.4.5.js => jquery.loadTemplate-1.5.0.js} | 27 ++++++++++---------
.../jquery.loadTemplate-1.5.0.min.js | 1 +
loadTemplate.jquery.json | 2 +-
tests/index.html | 2 +-
8 files changed, 21 insertions(+), 18 deletions(-)
delete mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js
rename jquery-loadTemplate/{jquery.loadTemplate-1.4.5.js => jquery.loadTemplate-1.5.0.js} (97%)
create mode 100644 jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js
diff --git a/Examples/SimpleExample/example.html b/Examples/SimpleExample/example.html
index 6f77930..d5fc7a4 100644
--- a/Examples/SimpleExample/example.html
+++ b/Examples/SimpleExample/example.html
@@ -88,7 +88,7 @@
Example of loading a template from a script tag within the same document.
-
+
diff --git a/bower.json b/bower.json
index 01af15b..b33029b 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery-load-template",
- "version": "1.4.5",
+ "version": "1.5.0",
"authors": [
{ "name": "Paul Burgess"}
],
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js
deleted file mode 100644
index 64dab52..0000000
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.5.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(I,A,F){F=F||{};var z=this,J=A.length,C=F.prepend&&!F.append,B=0,H=0,D=false,E;if(F.paged){var G=(F.pageNo-1)*F.elemPerPage;A=A.slice(G,G+F.elemPerPage);J=A.length}E=a.extend({},F,{complete:function(){if(this.html){if(C){z.prepend(this.html())}else{z.append(this.html())}}B++;if(B===J||D){if(D&&F&&typeof F.error==="function"){F.error.call(z)}if(F&&typeof F.complete==="function"){F.complete()}}},success:function(){H++;if(H===J){if(F&&typeof F.success==="function"){F.success()}}},error:function(){D=true}});if(!F.append&&!F.prepend){z.html("")}if(C){A.reverse()}a(A).each(function(){var K=a("");n.call(K,I,this,E);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(){k(D,B,A,C)}})}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)}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)}});if(typeof A.complete==="function"){A.complete.call(a(this))}}function k(C,A,z,B){var D;if(typeof B.error==="function"){B.error.call(A)}a(u[C]).each(function(E,F){if(typeof F.settings.error==="function"){F.settings.error.call(F.selection)}});if(typeof B.complete==="function"){B.complete.call(A)}while(u[C]&&(D=u[C].shift())){if(typeof D.settings.complete==="function"){D.settings.complete.call(D.selection)}}if(typeof u[C]!=="undefined"&&u[C].length>0){u[C]=[]}}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.4.5.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
similarity index 97%
rename from jquery-loadTemplate/jquery.loadTemplate-1.4.5.js
rename to jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
index 46275a8..209cfa3 100644
--- a/jquery-loadTemplate/jquery.loadTemplate-1.4.5.js
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.js
@@ -83,6 +83,7 @@
done = 0,
success = 0,
errored = false,
+ errorObjects = [],
newOptions;
if (settings.paged) {
@@ -95,6 +96,7 @@
{},
settings,
{
+ async: false,
complete: function () {
if (this.html) {
if (doPrepend) {
@@ -106,7 +108,7 @@
done++;
if (done === todo || errored) {
if (errored && settings && typeof settings.error === "function") {
- settings.error.call($that);
+ settings.error.call($that, errorObjects);
}
if (settings && typeof settings.complete === "function") {
settings.complete();
@@ -121,8 +123,9 @@
}
}
},
- error: function () {
+ error: function (e) {
errored = true;
+ errorObjects.push(e);
}
}
);
@@ -188,8 +191,8 @@
$templateContainer.html(templateContent);
handleTemplateLoadingSuccess($templateContainer, template, selection, data, settings);
},
- error: function () {
- handleTemplateLoadingError(template, selection, data, settings);
+ error: function (e) {
+ handleTemplateLoadingError(template, selection, data, settings, e);
}
});
}
@@ -215,7 +218,7 @@
$(this).each(function () {
var $templateHtml = $(template.html());
if (settings.beforeInsert) {
- settings.beforeInsert($templateHtml);
+ settings.beforeInsert($templateHtml, data);
}
if (settings.append) {
@@ -226,7 +229,7 @@
$(this).html($templateHtml);
}
if (settings.afterInsert) {
- settings.afterInsert($templateHtml);
+ settings.afterInsert($templateHtml, data);
}
});
@@ -235,16 +238,16 @@
}
}
- function handleTemplateLoadingError(template, selection, data, settings) {
+ function handleTemplateLoadingError(template, selection, data, settings, error) {
var value;
if (typeof settings.error === "function") {
- settings.error.call(selection);
+ settings.error.call(selection, error);
}
$(queue[template]).each(function (key, value) {
if (typeof value.settings.error === "function") {
- value.settings.error.call(value.selection);
+ value.settings.error.call(value.selection, error);
}
});
@@ -309,7 +312,7 @@
}, function ($elem) {
$elem.remove();
});
-
+
processElements("data-href", template, data, settings, function ($elem, value) {
$elem.attr("href", applyFormatters($elem, value, "href", settings));
}, function ($elem) {
@@ -520,9 +523,9 @@
var parentElement = options.parentElement || "div";
var template = options.template || options;
-
+
//If a parent is specified, return it; otherwise only return the generated children.
- if(options.parentElement)
+ if (options.parentElement)
return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings);
else
return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings).children();
diff --git a/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js
new file mode 100644
index 0000000..1333b7b
--- /dev/null
+++ b/jquery-loadTemplate/jquery.loadTemplate-1.5.0.min.js
@@ -0,0 +1 @@
+(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/loadTemplate.jquery.json b/loadTemplate.jquery.json
index 3ff9610..383ad61 100644
--- a/loadTemplate.jquery.json
+++ b/loadTemplate.jquery.json
@@ -6,7 +6,7 @@
"templates",
"templating"
],
- "version": "1.4.5",
+ "version": "1.5.0",
"author": {
"name": "Paul Burgess and other contributors",
"url": "https://github.com/codepb/jquery-template"
diff --git a/tests/index.html b/tests/index.html
index e1d7e36..e70f28a 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -3,7 +3,7 @@
loadTemplate Test Suite
-
+
From 68a627762d2cc2ec50c0c08839d007f82ae1f831 Mon Sep 17 00:00:00 2001
From: Paul Burgess
Date: Thu, 3 Sep 2015 15:45:52 +0100
Subject: [PATCH 12/34] updating package.json
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 84b6879..a1ac9c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jquery.loadtemplate",
- "version": "1.4.5",
+ "version": "1.5.0",
"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 5a34a469fed9195bf03450912827a75ba9daf69b Mon Sep 17 00:00:00 2001
From: Laurent
Date: Tue, 22 Sep 2015 14:33:20 +0200
Subject: [PATCH 13/34] bower.json fix
---
bower.json | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bower.json b/bower.json
index b33029b..19cae22 100644
--- a/bower.json
+++ b/bower.json
@@ -8,7 +8,7 @@
"repository": {
"type": "git",
"url": "git://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": [
@@ -22,7 +22,7 @@
"MIT-LICENSE.txt",
"package.json",
"readme.md"
- ]
+ ],
"keywords": [
"templates",
"templating",
@@ -30,5 +30,5 @@
],
"dependencies": {
"jquery": ">=1.8"
- },
+ }
}
From f2a788762d631076e086812e72fbbf9c50a6a09e Mon Sep 17 00:00:00 2001
From: codepb
Date: Mon, 30 Nov 2015 10:29:16 +0000
Subject: [PATCH 14/34] Update to include information about arrays
Fixes #78
---
readme.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index 7ed4472..b8cb88b 100644
--- a/readme.md
+++ b/readme.md
@@ -58,6 +58,10 @@ Similarly the content of the template could be held in a separate html file with
The plugin has a number of data-... attributes that can be used to populate various attributes with the data. There is also the powerful data-template-bind attribute that accepts a JSON object, enabling binding to any attribute, or the content of the element.
+#### Arrays
+
+You can pass an array of objects instead of a single object and the template will be populated and added to the container for each item in the array. There are options built in that allow you to page the results from an array as well. See the options section below and the included examples.
+
### 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:
@@ -95,7 +99,7 @@ Formatters must be added before they are used else a template will not be able t
### Bindings
There are a number of different bindings and ways to bind the data. The following attributes are available:
-- "data-innerHTML" (<= 1.4.5) - binds the value supplied to the content (innerHTML) of the element (uses $(elem).html(value))
+- "data-innerHTML" (>= 1.4.5) - binds the value supplied to the content (innerHTML) of the element (uses $(elem).html(value))
- "data-content" - alias for the newer "data-innerHTML"
- "data-content-text" - binds the value supplied to the content of the element as text (uses $(elem).text(value))
- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value))
From 8935e352a20f5838e3d5755b8b3927c2ef1e593b Mon Sep 17 00:00:00 2001
From: sorenwojo
Date: Thu, 21 Jan 2016 16:42:54 +0100
Subject: [PATCH 15/34] 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 16/34] 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 17/34] 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 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 19/34] 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 20/34] 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 21/34] 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 22/34] 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 23/34] 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 24/34] 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 25/34] 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 26/34] 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.
-
+