Comparing version 0.9.4 to 0.9.5
@@ -27,3 +27,3 @@ { | ||
}, | ||
"version" : "0.9.4" | ||
"version" : "0.9.5" | ||
} |
@@ -85,3 +85,3 @@ !function(m8) { | ||
util : "__UTIL__" | ||
}, fn_end = format("$C.destroy(); return {0};\n ", fn_var.output), fn_start = '\n"use strict";\n' + format('var $C = new ContextStack( {0}, this.fallback ), $_ = $C.current(), iter = new Iter( null ), {1} = "", U;', fn_var.dict, fn_var.output), id_count = 999, internals, logger = "console", re_br = /[\n\r]/gm, re_esc = /(['"])/g, re_format_delim = new RegExp(delim, "gm"), re_new_line = /[\r\n]+/g, re_space = /\s+/g, re_special_char = /[\(\)\[\]\{\}\?\*\+\/<>%&=!-]/, re_split_tpl, re_statement_fix = /\.(\d+)(\.?)/g, re_statement_replacer = "['$1']$2", re_statement_split = new RegExp("\\s*([^\\|]+(?:\\|[^\\|]+?)){0,}" + delim, "g"), split_token = "<__SPLIT__TEMPL8__HERE__>", split_replace = [ "", "$1", "$2", "" ].join(split_token), tpl = {}, tpl_id = "t8-anon-{0}", tpl_statement = '{0}["{1}"].call( this, {2}{3}, {4} )', tpl_sub = "{0}.{1}"; | ||
}, fn_end = format("return {0};\n ", fn_var.output), fn_start = '\n"use strict";\n' + format('var $C = new ContextStack( {0}, this.fallback ), $_ = $C.current(), iter = new Iter( null ), {1} = "", U;', fn_var.dict, fn_var.output), id_count = 999, internals, logger = "console", re_br = /[\n\r]/gm, re_esc = /(['"])/g, re_format_delim = new RegExp(delim, "gm"), re_new_line = /[\r\n]+/g, re_space = /\s+/g, re_special_char = /[\(\)\[\]\{\}\?\*\+\/<>%&=!-]/, re_split_tpl, re_statement_fix = /\.(\d+)(\.?)/g, re_statement_replacer = "['$1']$2", re_statement_split = new RegExp("\\s*([^\\|]+(?:\\|[^\\|]+?)){0,}" + delim, "g"), split_token = "<__SPLIT__TEMPL8__HERE__>", split_replace = [ "", "$1", "$2", "" ].join(split_token), tpl = {}, tpl_id = "t8-anon-{0}", tpl_statement = '{0}["{1}"].call( this, {2}{3}, {4} )', tpl_sub = "{0}.{1}"; | ||
function contains(o, k) { | ||
@@ -149,8 +149,2 @@ return typeof o.indexOf == "function" && !!~o.indexOf(k) || m8.got(o, k); | ||
}, | ||
destroy : function ContextStack_destroy() { | ||
this.destroyed = true; | ||
delete this[cache_key]; | ||
delete this[cache_stack]; | ||
return this; | ||
}, | ||
get : function ContextStack_get(key) { | ||
@@ -161,3 +155,3 @@ var ctx, stack = this[cache_stack], l = stack.length, val; | ||
if (key in ctx.cache) return ctx.cache[key]; | ||
if ((val = Object.value(ctx.dict, key)) !== U) return ctx.cache[key] = val; | ||
if ((val = ctx.dict[key]) !== U || (val = Object.value(ctx.dict, key)) !== U) return ctx.cache[key] = val; | ||
} | ||
@@ -173,3 +167,3 @@ return this.hasFallback ? this.fallback : U; | ||
this[cache_stack].push(this.top = { | ||
cache : {}, | ||
cache : m8.obj(), | ||
dict : dict | ||
@@ -186,3 +180,3 @@ }); | ||
if (!(len = keys.length)) return this.stop(); | ||
m8.nativeType(iter) == "object" || (keys = keys.map(Number)); | ||
m8.tostr(iter) == "[object Object]" || (keys = keys.map(Number)); | ||
this.empty = false; | ||
@@ -192,7 +186,3 @@ this.count = isNaN(count) ? len : count < 0 ? len + count : count > len ? len : count; | ||
this.index1 = this.index + 1; | ||
this.firstKey = keys[0]; | ||
this.first = iter[this.firstKey]; | ||
this.lastIndex = this.count - 1; | ||
this.lastKey = keys[this.lastIndex]; | ||
this.last = iter[this.lastKey]; | ||
this.keys = keys; | ||
@@ -206,8 +196,4 @@ !(parent instanceof Iter) || (this.parent = parent); | ||
++this.index < this.lastIndex || (this.stop().isLast = true); | ||
this.key = this.keys[this.index]; | ||
this.nextKey = this.keys[++this.index1] || U; | ||
this.previousKey = this.keys[this.index - 1] || U; | ||
this.key = this.keys[this.index1++]; | ||
this.current = this._[this.key]; | ||
this.next = this._[this.nextKey] || U; | ||
this.previous = this._[this.previousKey] || U; | ||
return this; | ||
@@ -220,2 +206,44 @@ }, | ||
}; | ||
m8.defs(Iter.prototype, { | ||
first : { | ||
get : function() { | ||
return this._[this.keys[0]]; | ||
} | ||
}, | ||
last : { | ||
get : function() { | ||
return this._[this.keys[this.lastIndex]]; | ||
} | ||
}, | ||
next : { | ||
get : function() { | ||
return this._[this.keys[this.index + 1]] || U; | ||
} | ||
}, | ||
prev : { | ||
get : function() { | ||
return this._[this.keys[this.index - 1]] || U; | ||
} | ||
}, | ||
firstKey : { | ||
get : function() { | ||
return this.keys[0]; | ||
} | ||
}, | ||
lastKey : { | ||
get : function() { | ||
return this.keys[this.lastIndex]; | ||
} | ||
}, | ||
nextKey : { | ||
get : function() { | ||
return this.keys[this.index + 1] || U; | ||
} | ||
}, | ||
prevKey : { | ||
get : function() { | ||
return this.keys[this.index - 1] || U; | ||
} | ||
} | ||
}, "r"); | ||
function aggregatetNonEmpty(res, str) { | ||
@@ -253,4 +281,5 @@ m8.empty(str) || res.push(str); | ||
} | ||
var func = new Function("root", "ContextStack", "Iter", fn_var.filter, fn_var.assert, fn_var.util, fn_var.dict, fn); | ||
return func.bind(ctx, m8.global, ContextStack, Iter, m8.copy(ctx.filters, Templ8.Filter.all(), true), ba, bu); | ||
var func = (new Function("root", "ContextStack", "Iter", fn_var.filter, fn_var.assert, fn_var.util, fn_var.dict, fn)).bind(ctx, m8.global, ContextStack, Iter, m8.copy(ctx.filters, Templ8.Filter.all(), true), ba, bu); | ||
m8.def(func, "src", m8.describe(fn, "r")); | ||
return func; | ||
} | ||
@@ -257,0 +286,0 @@ function createTemplate(ctx) { |
54223
696