Permalink
Browse files

Change output operator from '-' to '='

  • Loading branch information...
1 parent e1cf4cd commit ca79c8f626b9d7bc2d24b2d1628d32701cbe6a3f @baryshev committed Mar 1, 2012
Showing with 5 additions and 5 deletions.
  1. +2 −2 README.md
  2. +1 −1 examples/view/layout.html
  3. +1 −1 just.min.js
  4. +1 −1 lib/just.js
View
4 README.md
@@ -35,7 +35,7 @@ You may use JavaScript object as root.
var JUST = require('just');
var just = new JUST({ root : {
- layout: '<html><head><title><%- title %></title></head><body><%*%></body></html>',
+ layout: '<html><head><title><%= title %></title></head><body><%*%></body></html>',
page: '<%! layout %><p>Page content</p>'
}
});
@@ -53,7 +53,7 @@ See full example in [examples](https://github.com/baryshev/just/tree/master/exam
### Output
```
-<%- someVar %>
+<%= someVar %>
```
### JavaScript code
View
2 examples/view/layout.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title><%- title %></title>
+ <title><%= title %></title>
</head>
<body>
<header><%@ header %></header>
View
2 just.min.js
@@ -16,4 +16,4 @@
* Copyright Joyent, Inc. and other Node contributors
* Released under the MIT license
*/
-(function(){var s,path;var t=function(){var h={};var j=function(a,b){if(a.forEach){return a.forEach(b)}for(var i=0;i<a.length;i+=1){b(a[i],i,a)}};var k=function(b,c){if(b.map){return b.map(c)}var d=[];j(b,function(x,i,a){d.push(c(x,i,a))});return d};var l=function(c,d,e,f){var g=[];d=k(d,function(x,i){return{index:i,value:x}});c(d,function(x,b){e(x.value,function(a,v){g[x.index]=v;b(a)})},function(a){f(a,g)})};h.forEach=function(b,c,d){if(!b.length){return d()}var e=0;j(b,function(x){c(x,function(a){if(a){d(a);d=function(){}}else{e+=1;if(e===b.length){d()}}})})};var m=function(b){return function(){var a=Array.prototype.slice.call(arguments);return b.apply(null,[h.forEach].concat(a))}};h.map=m(l);h.parallel=function(e,f){f=f||function(){};if(e.constructor===Array){h.map(e,function(c,d){if(c){c(function(a){var b=Array.prototype.slice.call(arguments,1);if(b.length<=1){b=b[0]}d.call(null,a,b)})}},f)}};return h}();var u=function(k){var l={open:'<%',close:'%>',ext:'.html',useCache:true,watchForChanges:false,root:''},cache={},loaders={},watchers={};this.configure=function(a){for(var b in l){l[b]=a[b]||l[b]}};this.render=function(a,b,c){var d=new r(a,b);d.render(c)};this.configure(k);var m=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,'\\$1')};var n=function(a){var b=1,buffer=['with (this.data) { with (this.customData) { this.buffer.push(\''];var c=a.split(new RegExp(m(l.open)+'((?:.|[\r\n])+?)(?:'+m(l.close)+'|$)'));for(var i=0,length=c.length;i<length;i++){var d=c[i];if(i&1){var e,postfix,line='this.line='+b,jsFromPos=1;switch(d.charAt(0)){case'@':e='\', ('+line+', this.partial(\'';postfix='\')), \'';break;case'!':e='\', ('+line+', this.extend(\'';postfix='\')), \'';break;case'*':e='\', ('+line+', this.child(\'';postfix='\')), \'';break;case'[':e='\');'+line+';this.blockStart(\'';postfix='\'); this.buffer.push(\'';break;case']':e='\');'+line+';this.blockEnd(';postfix='); this.buffer.push(\'';break;case'-':e='\', ('+line+', ';postfix='), \'';break;default:e='\');'+line+';';postfix='; this.buffer.push(\'';jsFromPos=0}buffer.push(e,d.substr(jsFromPos).replace(/^\s+|\s+$/g,''),postfix)}else{buffer.push(d.replace(/[\\']/g,'\\$&').replace(/\r/g,' ').replace(/\n/g,'\\n'))}b+=d.split(/\n/).length-1}buffer.push('\'); } } return this.buffer;');buffer=buffer.join('');return new Function(buffer)};var o=function(c,d,e){t.forEach(loaders[d],function(a,b){a(c,e);b()},function(){delete(loaders[d])})};var p=function(a,b){if(Object.prototype.toString.call(l.root)==='[object Object]'){try{var c=eval('(options.root.'+a+')');if(Object.prototype.toString.call(c)==='[object String]'){b(undefined,c)}else{b('Failed to load template')}}catch(e){b(e)}}else{s.readFile(a,'utf8',b)}};var q=function(d,f){if(l.useCache&&cache[d]){f&&f(undefined,cache[d])}else{if(!loaders[d]){loaders[d]=[];f&&loaders[d].push(f);p(d,function(a,b){if(a){o(a,d,undefined)}else{try{var c=n(b);o(undefined,d,c);if(l.useCache){cache[d]=c}if(l.watchForChanges){watchers[d]=s.watch(d,function(){watchers[d].close();delete(watchers[d]);delete(cache[d])})}}catch(e){e.message=e.message+' in '+d;o(e,d,undefined)}}})}else{f&&loaders[d].push(f)}}};var r=function(a,b,c){this.file=a;if(Object.prototype.toString.call(l.root)==='[object String]'){this.file=path.normalize(l.root+'/'+a+l.ext)}this.data=b;this.customData=c||{};this.buffer=[];this.tmpBuffer=undefined;this.watcher=undefined;this.line=1;this.partials=[];this.childData=[];this.childError=undefined;this.childCallback=undefined;this.callback=undefined;this.blocks={}};r.prototype.blockStart=function(a){this.tmpBuffer=this.buffer;if(!this.blocks[a])this.blocks[a]=[];if(!this.blocks[a].length){this.buffer=this.blocks[a]}else{this.buffer=[]}};r.prototype.blockEnd=function(){this.buffer=this.tmpBuffer;delete(this.tmpBuffer)};r.prototype.partial=function(d,e){var f=[];var g=new r(d,this.data,e);this.partials.push(function(c){g.render(function(a,b){if(!a)f.push(b);c(a)})});return f};r.prototype.extend=function(c,d){var e=new r(c,this.data,d);e.blocks=this.blocks;var f=this.callback;this.callback=function(a,b){if(a){e.childError=a;e.childCallback&&e.childCallback(a)}else{e.childData.push(b);e.childCallback&&e.childCallback()}};e.partials.push(function(a){if(e.childError){a(e.childError)}else if(e.childData.length){a()}else{e.childCallback=a}});e.render(f);return''};r.prototype.child=function(a){if(a&&a.length){if(!this.blocks[a])this.blocks[a]=[];return this.blocks[a]}else{return this.childData}};r.prototype.render=function(h){var j=this;this.callback=h;q(this.file,function(d,f){if(d){j.callback&&j.callback(d,undefined)}else{try{var g=f.call(j);t.parallel(j.partials,function(a){var b='';if(!a){var c=g.length;for(var i=0;i<c;i++){b+=(Array.isArray(g[i]))?g[i].join(''):g[i]}}j.callback&&j.callback(a,b)})}catch(e){e.message=e.message+' in '+j.file+' on line '+j.line;j.callback&&j.callback(e,undefined)}}})}};if(typeof module!=='undefined'&&module.exports){s=require('fs');path=require('path');module.exports=u}else{if(!Array.prototype.filter){Array.prototype.filter=function(a){var b=this.length;if(typeof a!="function")throw new TypeError();var c=new Array();var d=arguments[1];for(var i=0;i<b;i++){if(i in this){var e=this[i];if(a.call(d,e,i,this))c.push(e)}}return c}}if(!Array.isArray){Array.isArray=function(a){return Object.prototype.toString.call(a)==='[object Array]'}}this.JUST=u;path=function(){var e=function(a,b){var c=0;for(var i=a.length-1;i>=0;i--){var d=a[i];if(d=='.'){a.splice(i,1)}else if(d==='..'){a.splice(i,1);c++}else if(c){a.splice(i,1);c--}}if(b){for(;c--;c){arts.unshift('..')}}return a};var f=function(a){var b=a.charAt(0)==='/',trailingSlash=a.slice(-1)==='/';a=e(a.split('/').filter(function(p){return!!p}),!b).join('/');if(!a&&!b){a='.'}if(a&&trailingSlash){a+='/'}return(b?'/':'')+a};return{normalize:f}}();var w=function(a,b){var c=this;this.updating=false;this.abort=function(){if(c.updating){c.updating=false;c.AJAX.abort();c.AJAX=null}};this.update=function(){if(c.updating){return false}c.AJAX=null;if(window.XMLHttpRequest){c.AJAX=new XMLHttpRequest();c.AJAX.overrideMimeType&&c.AJAX.overrideMimeType('text/html')}else{c.AJAX=new ActiveXObject('Microsoft.XMLHTTP')}if(c.AJAX==null){return false}else{c.AJAX.onreadystatechange=function(){if(c.AJAX.readyState==4){c.updating=false;c.callback(c.AJAX.responseText,c.AJAX.status,c.AJAX.responseXML);c.AJAX=null}};c.updating=new Date();c.AJAX.open('GET',a,true);c.AJAX.send(null);return true}};this.callback=b||function(){}};s=function(){var h=function(c,d,f){var g=new w(c,function(a,b){if(b<200||b>399){f('Failed to load template')}else{f(undefined,a)}});try{g.update()}catch(e){f(e)}};var i=function(){};return{readFile:h,watch:i}}()}}());
+(function(){var s,path;var t=function(){var h={};var j=function(a,b){if(a.forEach){return a.forEach(b)}for(var i=0;i<a.length;i+=1){b(a[i],i,a)}};var k=function(b,c){if(b.map){return b.map(c)}var d=[];j(b,function(x,i,a){d.push(c(x,i,a))});return d};var l=function(c,d,e,f){var g=[];d=k(d,function(x,i){return{index:i,value:x}});c(d,function(x,b){e(x.value,function(a,v){g[x.index]=v;b(a)})},function(a){f(a,g)})};h.forEach=function(b,c,d){if(!b.length){return d()}var e=0;j(b,function(x){c(x,function(a){if(a){d(a);d=function(){}}else{e+=1;if(e===b.length){d()}}})})};var m=function(b){return function(){var a=Array.prototype.slice.call(arguments);return b.apply(null,[h.forEach].concat(a))}};h.map=m(l);h.parallel=function(e,f){f=f||function(){};if(e.constructor===Array){h.map(e,function(c,d){if(c){c(function(a){var b=Array.prototype.slice.call(arguments,1);if(b.length<=1){b=b[0]}d.call(null,a,b)})}},f)}};return h}();var u=function(k){var l={open:'<%',close:'%>',ext:'.html',useCache:true,watchForChanges:false,root:''},cache={},loaders={},watchers={};this.configure=function(a){for(var b in l){l[b]=a[b]||l[b]}};this.render=function(a,b,c){var d=new r(a,b);d.render(c)};this.configure(k);var m=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,'\\$1')};var n=function(a){var b=1,buffer=['with (this.data) { with (this.customData) { this.buffer.push(\''];var c=a.split(new RegExp(m(l.open)+'((?:.|[\r\n])+?)(?:'+m(l.close)+'|$)'));for(var i=0,length=c.length;i<length;i++){var d=c[i];if(i&1){var e,postfix,line='this.line='+b,jsFromPos=1;switch(d.charAt(0)){case'@':e='\', ('+line+', this.partial(\'';postfix='\')), \'';break;case'!':e='\', ('+line+', this.extend(\'';postfix='\')), \'';break;case'*':e='\', ('+line+', this.child(\'';postfix='\')), \'';break;case'[':e='\');'+line+';this.blockStart(\'';postfix='\'); this.buffer.push(\'';break;case']':e='\');'+line+';this.blockEnd(';postfix='); this.buffer.push(\'';break;case'=':e='\', ('+line+', ';postfix='), \'';break;default:e='\');'+line+';';postfix='; this.buffer.push(\'';jsFromPos=0}buffer.push(e,d.substr(jsFromPos).replace(/^\s+|\s+$/g,''),postfix)}else{buffer.push(d.replace(/[\\']/g,'\\$&').replace(/\r/g,' ').replace(/\n/g,'\\n'))}b+=d.split(/\n/).length-1}buffer.push('\'); } } return this.buffer;');buffer=buffer.join('');return new Function(buffer)};var o=function(c,d,e){t.forEach(loaders[d],function(a,b){a(c,e);b()},function(){delete(loaders[d])})};var p=function(a,b){if(Object.prototype.toString.call(l.root)==='[object Object]'){try{var c=eval('(options.root.'+a+')');if(Object.prototype.toString.call(c)==='[object String]'){b(undefined,c)}else{b('Failed to load template')}}catch(e){b(e)}}else{s.readFile(a,'utf8',b)}};var q=function(d,f){if(l.useCache&&cache[d]){f&&f(undefined,cache[d])}else{if(!loaders[d]){loaders[d]=[];f&&loaders[d].push(f);p(d,function(a,b){if(a){o(a,d,undefined)}else{try{var c=n(b);o(undefined,d,c);if(l.useCache){cache[d]=c}if(l.watchForChanges){watchers[d]=s.watch(d,function(){watchers[d].close();delete(watchers[d]);delete(cache[d])})}}catch(e){e.message=e.message+' in '+d;o(e,d,undefined)}}})}else{f&&loaders[d].push(f)}}};var r=function(a,b,c){this.file=a;if(Object.prototype.toString.call(l.root)==='[object String]'){this.file=path.normalize(l.root+'/'+a+l.ext)}this.data=b;this.customData=c||{};this.buffer=[];this.tmpBuffer=undefined;this.watcher=undefined;this.line=1;this.partials=[];this.childData=[];this.childError=undefined;this.childCallback=undefined;this.callback=undefined;this.blocks={}};r.prototype.blockStart=function(a){this.tmpBuffer=this.buffer;if(!this.blocks[a])this.blocks[a]=[];if(!this.blocks[a].length){this.buffer=this.blocks[a]}else{this.buffer=[]}};r.prototype.blockEnd=function(){this.buffer=this.tmpBuffer;delete(this.tmpBuffer)};r.prototype.partial=function(d,e){var f=[];var g=new r(d,this.data,e);this.partials.push(function(c){g.render(function(a,b){if(!a)f.push(b);c(a)})});return f};r.prototype.extend=function(c,d){var e=new r(c,this.data,d);e.blocks=this.blocks;var f=this.callback;this.callback=function(a,b){if(a){e.childError=a;e.childCallback&&e.childCallback(a)}else{e.childData.push(b);e.childCallback&&e.childCallback()}};e.partials.push(function(a){if(e.childError){a(e.childError)}else if(e.childData.length){a()}else{e.childCallback=a}});e.render(f);return''};r.prototype.child=function(a){if(a&&a.length){if(!this.blocks[a])this.blocks[a]=[];return this.blocks[a]}else{return this.childData}};r.prototype.render=function(h){var j=this;this.callback=h;q(this.file,function(d,f){if(d){j.callback&&j.callback(d,undefined)}else{try{var g=f.call(j);t.parallel(j.partials,function(a){var b='';if(!a){var c=g.length;for(var i=0;i<c;i++){b+=(Array.isArray(g[i]))?g[i].join(''):g[i]}}j.callback&&j.callback(a,b)})}catch(e){e.message=e.message+' in '+j.file+' on line '+j.line;j.callback&&j.callback(e,undefined)}}})}};if(typeof module!=='undefined'&&module.exports){s=require('fs');path=require('path');module.exports=u}else{if(!Array.prototype.filter){Array.prototype.filter=function(a){var b=this.length;if(typeof a!="function")throw new TypeError();var c=new Array();var d=arguments[1];for(var i=0;i<b;i++){if(i in this){var e=this[i];if(a.call(d,e,i,this))c.push(e)}}return c}}if(!Array.isArray){Array.isArray=function(a){return Object.prototype.toString.call(a)==='[object Array]'}}this.JUST=u;path=function(){var e=function(a,b){var c=0;for(var i=a.length-1;i>=0;i--){var d=a[i];if(d=='.'){a.splice(i,1)}else if(d==='..'){a.splice(i,1);c++}else if(c){a.splice(i,1);c--}}if(b){for(;c--;c){arts.unshift('..')}}return a};var f=function(a){var b=a.charAt(0)==='/',trailingSlash=a.slice(-1)==='/';a=e(a.split('/').filter(function(p){return!!p}),!b).join('/');if(!a&&!b){a='.'}if(a&&trailingSlash){a+='/'}return(b?'/':'')+a};return{normalize:f}}();var w=function(a,b){var c=this;this.updating=false;this.abort=function(){if(c.updating){c.updating=false;c.AJAX.abort();c.AJAX=null}};this.update=function(){if(c.updating){return false}c.AJAX=null;if(window.XMLHttpRequest){c.AJAX=new XMLHttpRequest();c.AJAX.overrideMimeType&&c.AJAX.overrideMimeType('text/html')}else{c.AJAX=new ActiveXObject('Microsoft.XMLHTTP')}if(c.AJAX==null){return false}else{c.AJAX.onreadystatechange=function(){if(c.AJAX.readyState==4){c.updating=false;c.callback(c.AJAX.responseText,c.AJAX.status,c.AJAX.responseXML);c.AJAX=null}};c.updating=new Date();c.AJAX.open('GET',a,true);c.AJAX.send(null);return true}};this.callback=b||function(){}};s=function(){var h=function(c,d,f){var g=new w(c,function(a,b){if(b<200||b>399){f('Failed to load template')}else{f(undefined,a)}});try{g.update()}catch(e){f(e)}};var i=function(){};return{readFile:h,watch:i}}()}}());
View
2 lib/just.js
@@ -151,7 +151,7 @@ var JUST = function(newOptions) {
prefix = '\');' + line + ';this.blockEnd(';
postfix = '); this.buffer.push(\'';
break;
- case '-' :
+ case '=' :
prefix = '\', (' + line + ', ';
postfix = '), \'';
break;

0 comments on commit ca79c8f

Please sign in to comment.