source: [view]
var location = ((this.constant) ? this.path : this.path.resolve(context)).toString();
var parsed = Number(this.parsed);
var dirty = false;
if(location != this.last){
dirty = true;
if(this.last){
buffer = this.unrender(context, buffer);
}
this.last = location;
}
var cache = this._cache[parsed];
if(parsed){
if(!cache[location]){
cache[location] = dd.text._resolveTemplateArg(location, true);
}
if(dirty){
var template = this.getTemplate(cache[location]);
this.rendered = template.nodelist;
}
return this.rendered.render(context, buffer, this);
}else{
if(this.text instanceof dd._TextNode){
if(dirty){
this.rendered = this.text;
this.rendered.set(dd.text._resolveTemplateArg(location, true));
}
return this.rendered.render(context, buffer);
}else{
if(!cache[location]){
var nodelist = [];
var div = document.createElement("div");
div.innerHTML = dd.text._resolveTemplateArg(location, true);
var children = div.childNodes;
while(children.length){
var removed = div.removeChild(children[0]);
nodelist.push(removed);
}
cache[location] = nodelist;
}
if(dirty){
this.nodelist = [];
var exists = true;
for(var i = 0, child; child = cache[location][i]; i++){
this.nodelist.push(child.cloneNode(true));
}
}
for(var i = 0, node; node = this.nodelist[i]; i++){
buffer = buffer.concat(node);
}
}
}
return buffer;