diff --git a/.gitignore b/.gitignore
index b9d6bd9..3835d69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+bower_components/
+node_modules/
+
#################
## Eclipse
#################
@@ -192,7 +195,6 @@ $RECYCLE.BIN/
# Packages
*.egg
*.egg-info
-dist/
build/
eggs/
parts/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6282792
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,2 @@
+before_script : cd tests
+script: phantomjs phantom.js
diff --git a/Examples/ExampleSearchResults/Services/searchResults.txt b/Examples/ExampleSearchResults/Services/searchResults.txt
index 3fa09c0..544cf01 100644
--- a/Examples/ExampleSearchResults/Services/searchResults.txt
+++ b/Examples/ExampleSearchResults/Services/searchResults.txt
@@ -2,7 +2,7 @@
{
"id": 2,
"name": "An ice sculpture",
- "price": 12.50,
+ "price": 0.00,
"tags": ["cold", "ice", "sculpture"],
"dimensions": {
"length": 7.0,
diff --git a/Examples/ExampleSearchResults/search.html b/Examples/ExampleSearchResults/search.html
index 36a5cb3..f1c2f13 100644
--- a/Examples/ExampleSearchResults/search.html
+++ b/Examples/ExampleSearchResults/search.html
@@ -24,10 +24,12 @@
Example of using jQuery.loadTemplate for improved search.
+
+
+
+
+
+
+
+
+
+
+
+
+
+Loaded with function parameters
+
+
+
+
+
+
+Loaded with template parameters
+
+
+
+
+
+
+Loaded with template as data-bind-template attribute
+
+
+
+
+Loaded with nested template with function parameters
+
+
+
diff --git a/Examples/SimpleExample/Templates/simple.html b/Examples/SimpleExample/Templates/simple.html
index e69c81a..2e75af5 100644
--- a/Examples/SimpleExample/Templates/simple.html
+++ b/Examples/SimpleExample/Templates/simple.html
@@ -2,9 +2,11 @@
\ No newline at end of file
+ {"attribute": "innerHTML", "value": "post"},
+ {"attribute": "data-date", "value": "date"},
+ {"attribute": "data-author", "value": "author", "formatter": "sameCaseFormatter", "formatOptions": "upper"}]'>
+
+
diff --git a/Examples/SimpleExample/example.html b/Examples/SimpleExample/example.html
index 3409685..d54b719 100644
--- a/Examples/SimpleExample/example.html
+++ b/Examples/SimpleExample/example.html
@@ -9,64 +9,113 @@ Example of loading a template from a script tag within the same document.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
+
+ var sampleData = {
+ testSingle: "singleString",
+ testArray: ["testString1", "testString2", "testString3", 4],
+ selectedItem: "testString2"
+ }
+
+ $(".this-test").loadTemplate("#templateThis", ["testString1", "testString2", "testString3", 4]);
+
+ $(".nested").loadTemplate("#nestTest", sampleData);
+
+ var data = [{ "month": "Juli",
+ "records": [{ "full_date": "01.06.2014"}]
+ },
+ { "month": "August",
+ "records": [{ "full_date": "01.07.2014"}]
+ }];
+
+ $('#sampleContainer').loadTemplate("#outerTemplate", data);
+ });
+
diff --git a/Examples/index.html b/Examples/index.html
index 72df701..f14d59a 100644
--- a/Examples/index.html
+++ b/Examples/index.html
@@ -1,5 +1,4 @@
-
@@ -9,8 +8,8 @@
-
-
+
+
@@ -49,7 +49,7 @@ Code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/phantom.js b/tests/phantom.js
new file mode 100644
index 0000000..23451f9
--- /dev/null
+++ b/tests/phantom.js
@@ -0,0 +1,79 @@
+
+var page = require('webpage').create();
+var fs = require('fs');
+
+page.onConsoleMessage = function (msg, line, source) {
+ console.error(msg);
+};
+
+page.onClosing = function(){
+ console.log('closed');
+};
+
+function createReport(obj) {
+
+ var totalErrors = 0,
+ totalPasses = 0;
+
+ console.log("======================================");
+ for (key in obj){
+ var report = obj[key],
+ reportText = " \n " + key + " ";
+
+ totalPasses += report.passes;
+ totalErrors += report.fails;
+ if (report.fails > 0) {
+ reportText += '.....(faild)';
+ for (name in report.errors){
+ reportText += '\n -> ' + name;
+ var list = report.errors[name];
+ for(var i = 0; i < list.length; i++){
+ reportText += '\n --> ' + list[i];
+ }
+ }
+ } else {
+ reportText += '......(ok)';
+ }
+ console.log(reportText);
+ }
+
+ console.log("\n======================================");
+ console.log("= Done Testing");
+ console.log("= Total Tests : " + (totalPasses + totalErrors));
+ console.log("= Passed Tests: " + totalPasses);
+ console.log("= Failed Tests: " + totalErrors);
+
+ //page.render('view.png');
+ phantom.exit(totalErrors);
+}
+
+//this should be run on a server
+//but for now local file seems ok
+page.open('index.html', function(status) {
+ //var timeout = setTimeout(function(){
+ var evaluate = function(){
+ return page.evaluate(function(phantom) {
+ if (phantomExit) {
+ return phantomReport;
+ }
+ return false;
+ });
+ };
+
+ var timeout;
+ var interv = setInterval(function(){
+ var ret = evaluate();
+ if (typeof ret === 'object') {
+ createReport(ret);
+ clearInterval(this);
+ if (timeout) clearTimeout(timeout);
+ }
+ },100);
+
+ //on timeout
+ timeout = setTimeout(function(){
+ clearInterval(interv);
+ createReport(ret);
+ },10000);
+
+});
diff --git a/tests/testRunner.js b/tests/testRunner.js
new file mode 100644
index 0000000..8d1461c
--- /dev/null
+++ b/tests/testRunner.js
@@ -0,0 +1,111 @@
+var testObject = [];
+var scriptTestFiles = [];
+var currnetTestFileCounter = 0;
+var phantomReport = {};
+var phantomExit = false;
+
+function addTests() {
+
+ for (var i = 0; i < arguments.length; i++){
+ testObject.push(arguments[i]);
+ }
+
+ var file = scriptTestFiles[currnetTestFileCounter++];
+ //hack wru to get better reporting
+ testObject.push(function(){
+ return {
+ teardown :function(){
+ var ele = $('#wru').find('div:last');
+ var report = $(' Done Testsing ' + file + '
');
+ $('#wru').append(report);
+
+ var elements = $('.testfile:last').prevUntil('.testfile'),
+ errors = 0,
+ passes = 0;
+
+ var phantom = phantomReport[file] = {
+ errors : {},
+ passes : 0,
+ fails : 0
+ };
+
+ elements.each(function(){
+ var error = $(this).find('li');
+ errors += error.length;
+ if (error.length > 0) {
+ var errorText = $(this).children().first().text();
+ phantom.errors[errorText] = [];
+ $(error).each(function(){
+ phantom.errors[errorText].push($(this).text());
+ });
+ }
+
+ var pass = $(this).find('span:first').text();
+ if (pass) {
+ var n = /\w+\s+\((\d+)/.exec(pass);
+ if (n) passes += parseInt(n[1]);
+ }
+ });
+
+ phantom.passes = passes;
+ phantom.fails = errors;
+ if (errors > 0) {
+ report.text(report.text() + " ( " + errors + " Errors & " + passes + " Passed )").css({
+ background : "red",
+ color : "white"
+ });
+ } else {
+ report.text(report.text() + " ( " + passes + " Tests Passed )");
+ }
+
+ ele.remove();
+ }
+ }
+ return false;
+ });
+}
+
+function loadTestFile(src){
+ document.write('<' + 'script src="' + src + '"' +
+ ' type="text/javascript"><' + '/script>');
+}
+
+function runTests(files) {
+ $(files).each(function(i,val){
+ scriptTestFiles.push(val);
+ loadTestFile(val);
+ });
+}
+
+function wru(wru){
+ var assert = wru.assert,
+ async = wru.async,
+ log = wru.log;
+
+ testObject.push(function(assert,async){
+ return {
+ name : '',
+ teardown : function(){
+ $('.final').parent().hide();
+ phantomExit = true;
+ }
+ };
+ });
+
+ var run = function(obj){
+ for (var i = 0; i < obj.length; i++){
+ var action = obj[i];
+ if ($.isArray(action)) {
+ run(action);
+ continue;
+ }
+ var ret = obj[i](assert,async);
+ if (ret) wru.test(ret);
+ }
+ };
+
+ run(testObject);
+ //remove wru headers as we generated our own header reports
+ $('#wru').find('strong:not(:first)').remove();
+ $('#wru').find('.fail strong').remove();
+}
diff --git a/tests/wru.js b/tests/wru.js
new file mode 100644
index 0000000..f8feede
--- /dev/null
+++ b/tests/wru.js
@@ -0,0 +1 @@
+wru(function(Y){function j(){A=K.call(m);if(A){if(typeof A=="function"){A={name:A[S]||"anonymous",test:A}}(P=l(l(Z.node,"div"),"span"))[E]=((ag(A,S)&&A[S])||(ag(A,e)&&A[e])||Q)+i+i;a=[];u=[];T=[];ab={};b("setup");T[ah]||b("test");N||r()}else{t()}}function p(aj){try{return O.call(h,aj)}catch(ai){return h.createElement(aj)}}function l(ai,aj){return ai.appendChild(p(aj))}function g(ai){P[E]=x.call(P[E],0,-2)+i+ai}function t(){var ak=Z.node.insertBefore(p("div"),Z.node.firstChild),al,aj,ai;if(ad){ai=aj="error";al="There Are Errors: "+ad}else{if(C){ai=aj="fail";al=C+" Tests Failed"}else{ai=aj="pass";al="Passed "+s+" Tests"}}Z.status=ai;ak[E]=""+al+"";ak.className=aj}function G(){var ai=this.lastChild.style;ai.display=ai.display=="none"?"block":"none"}function c(ai){P[E]+="";(P.onclick=G).call(P)}function r(){f();s+=a[ah];C+=u[ah];ad+=T[ah];g("("+v.call([a[ah],M=u[ah],T[ah]],", ")+")");P=P.parentNode;T[ah]?c(T,W="error"):(M?c(u,W="fail"):W="pass");P.className=W;M=0;W=i;j()}function b(ai){if(ag(A,ai)){try{A[ai](ab)}catch(aj){aa.call(T,i+aj)}}}function ag(aj,ai){return q.call(aj,ai)}function w(){return F()<0.5?-1:1}function f(){if(R){H(R);R=0}b("teardown")}var Z={timeout:y,assert:function U(aj,ai){if(arguments[ah]==1){ai=aj;aj=Q}z=I;aa.call(ai?a:u,W+aj);return ai},async:function V(ak,an,al,am){var ai=al||Z.timeout||(Z.timeout=y);am=++N;if(typeof ak=="function"){ai=an||Z.timeout;an=ak;ak="asynchronous test #"+am}al=X(function(){am=0;aa.call(u,ak);--N||(R=X(r,0))},L(ai)||Z.timeout);return function aj(){if(!am){return}z=ae;W=ak+": ";try{an.apply(this,arguments)}catch(ao){z=I;aa.call(T,W+ao)}W=i;if(z){H(al);--N||(R=X(r,0))}}},test:function n(ai,aj){Z.after=aj||function(){};m=J.apply(m,[ai]);Z.random&&af.call(m,w);N||j()}},I=true,ae=!I,y=100,i=" ",Q="unknown",ah="length",S="name",e="description",D="",d="",k="\\|/-",q=Z.hasOwnProperty,W=i,ac=W.charAt,x=W.slice,m=[],J=m.concat,v=m.join,aa=m.push,K=m.shift,af=m.sort,N=0,M=0,s=0,C=0,ad=0,R=0,E="innerHTML",h=Y.document,O=h.createElement,B,L,F,X,H,A,P,a,u,T,ab,z;B=Y.Math;L=B.abs;F=B.random;X=Y.setTimeout;H=Y.clearTimeout;Z.node=(h.getElementById("wru")||h.body||h.documentElement);Y.setInterval(function(){N&&g(ac.call(k,M++%4))},y);undefined;Z.log=function o(aj,ai){ai?alert(aj):(typeof console!="undefined")&&console.log(aj)};y*=y;Z.random=ae;return Z}(this));