Permalink
Browse files

release v0.2.0

  • Loading branch information...
1 parent 9a268e8 commit e723e914099c184a93b1b353c6dc68b22d4c5890 akdubya committed Nov 29, 2010
@@ -1,5 +1,5 @@
//
-// Dust - Asynchronous Templating v0.1.0
+// Dust - Asynchronous Templating v0.2.0
// http://akdubya.github.com/dustjs
//
// Copyright (c) 2010, Aleksander Williams
@@ -23,7 +23,7 @@ dust.render = function(name, context, callback) {
dust.stream = function(name, context) {
var stream = new Stream();
- setTimeout(function() {
+ dust.nextTick(function() {
dust.load(name, stream.head, Context.wrap(context)).end();
});
return stream;
@@ -1,5 +1,5 @@
//
-// Dust - Asynchronous Templating v0.1.0
+// Dust - Asynchronous Templating v0.2.0
// http://akdubya.github.com/dustjs
//
// Copyright (c) 2010, Aleksander Williams
@@ -8,7 +8,7 @@
var dust={};
(function(d){function g(a,b,c){this.stack=a;this.global=b;this.blocks=c}function j(a,b,c,e){this.tail=b;this.isObject=!d.isArray(a)&&a&&typeof a==="object";this.head=a;this.index=c;this.of=e}function m(a){this.head=new f(this);this.callback=a;this.out=""}function k(){this.head=new f(this)}function f(a,b,c){this.root=a;this.next=b;this.data="";this.flushable=false;this.taps=c}function l(a,b){this.head=a;this.tail=b}d.cache={};d.register=function(a,b){d.cache[a]=b};d.render=function(a,b,c){c=(new m(c)).head;
-d.load(a,c,g.wrap(b)).end()};d.stream=function(a,b){var c=new k;setTimeout(function(){d.load(a,c.head,g.wrap(b)).end()});return c};d.load=function(a,b,c){return(tmpl=d.cache[a])?tmpl(b,c):b.setError(Error("Template Not Found: "+a))};d.loadSource=function(a){eval(a)};d.isArray=Array.isArray?Array.isArray:function(a){return Object.prototype.toString.call(a)=="[object Array]"};d.nextTick=function(a){setTimeout(a,0)};d.isEmpty=function(a){if(d.isArray(a)&&!a.length)return true;if(a===0)return false;return!a};
+d.load(a,c,g.wrap(b)).end()};d.stream=function(a,b){var c=new k;d.nextTick(function(){d.load(a,c.head,g.wrap(b)).end()});return c};d.load=function(a,b,c){return(tmpl=d.cache[a])?tmpl(b,c):b.setError(Error("Template Not Found: "+a))};d.loadSource=function(a){eval(a)};d.isArray=Array.isArray?Array.isArray:function(a){return Object.prototype.toString.call(a)=="[object Array]"};d.nextTick=function(a){setTimeout(a,0)};d.isEmpty=function(a){if(d.isArray(a)&&!a.length)return true;if(a===0)return false;return!a};
d.filter=function(a,b,c){for(var e=c.length,h=0;h<e;h++){var i=c[h];if(i==="s")b=null;else a=d.filters[i](a)}if(b)a=d.filters[b](a);return a};d.filters={h:function(a){return d.escapeHtml(a)},j:function(a){return d.escapeJs(a)},u:encodeURI,uc:encodeURIComponent};d.makeBase=function(a){return new g(new j,a)};g.wrap=function(a){if(a instanceof g)return a;return new g(new j(a))};g.prototype.get=function(a){for(var b=this.stack,c;b;){if(b.isObject){c=b.head[a];if(c!==undefined)return c}b=b.tail}return this.global?
this.global[a]:undefined};g.prototype.getPath=function(a,b){var c=this.stack,e=b.length;if(a&&e===0)return c.head;if(c.isObject){c=c.head;for(var h=0;c&&h<e;){c=c[b[h]];h++}return c}};g.prototype.push=function(a,b,c){return new g(new j(a,this.stack,b,c),this.global,this.blocks)};g.prototype.rebase=function(a){return new g(new j(a),this.global,this.blocks)};g.prototype.current=function(){return this.stack.head};g.prototype.getBlock=function(a){var b=this.blocks;if(b)for(var c=b.length,e;c--;)if(e=
b[c][a])return e};g.prototype.shiftBlocks=function(a){var b=this.blocks;if(a){newBlocks=b?b.concat([a]):[a];return new g(this.stack,this.global,newBlocks)}return this};m.prototype.flush=function(){for(var a=this.head;a;){if(a.flushable)this.out+=a.data;else{if(a.error){this.callback(a.error);this.flush=function(){}}return}this.head=a=a.next}this.callback(null,this.out)};k.prototype.flush=function(){for(var a=this.head;a;){if(a.flushable)this.emit("data",a.data);else{if(a.error){this.emit("error",
Oops, something went wrong.

0 comments on commit e723e91

Please sign in to comment.