dojox/dtl/tag/loader.js

  • Provides:

    • dojox.dtl.tag.loader
  • Requires:

    • dojox.dtl._base in common
  • dojox.dtl.tag.loader.BlockNode

    • type
      Function
    • parameters:
      • name: (typeof )
      • nodelist: (typeof )
    • source: [view]
        this.name = name;
        this.nodelist = nodelist; // Can be overridden
    • summary
  • dojox.dtl.tag.loader.ExtendsNode

    • type
      Function
    • parameters:
      • getTemplate: (typeof )
      • nodelist: (typeof )
      • shared: (typeof )
      • parent: (typeof )
      • key: (typeof )
    • source: [view]
        this.getTemplate = getTemplate;
        this.nodelist = nodelist;
        this.shared = shared;
        this.parent = parent;
        this.key = key;
    • summary
  • dojox.dtl.tag.loader.IncludeNode

    • type
      Function
    • parameters:
      • path: (typeof )
      • constant: (typeof )
      • getTemplate: (typeof )
      • text: (typeof )
      • parsed: (typeof )
    • source: [view]
        this._path = path;
        this.constant = constant;
        this.path = (constant) ? path : new dd._Filter(path);
        this.getTemplate = getTemplate;
        this.text = text;
        this.parsed = (arguments.length == 5) ? parsed : true;
    • summary
  • dojox.dtl.tag.loader.BlockNode.name

    • summary
  • dojox.dtl.tag.loader.BlockNode.nodelist

    • summary
  • dojox.dtl.tag.loader.BlockNode.super

    • type
      Function
    • source: [view]
         if(this.parent){
          var html = this.parent.nodelist.dummyRender(this.context, null, true);
          if(typeof html == "string"){
           html = new String(html);
          }
          html.safe = true;
          return html;
         }
         return '';
    • summary
  • dojox.dtl.tag.loader.BlockNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var name = this.name;
         var nodelist = this.nodelist;
         var parent;
         if(buffer.blocks){
          var block = buffer.blocks[name];
          if(block){
           parent = block.parent;
           nodelist = block.nodelist;
           block.used = true;
          }
         }


         this.rendered = nodelist;


         context = context.push();
         this.context = context;
         this.parent = null;
         if(nodelist != this.nodelist){
          this.parent = this;
         }
         context.block = this;


         if(buffer.getParent){
          var bufferParent = buffer.getParent();
          var setParent = dojo.connect(buffer, "onSetParent", function(node, up, root){
           if(up && root){
            buffer.setParent(bufferParent);
           }
          });
         }
         buffer = nodelist.render(context, buffer, this);
         setParent && dojo.disconnect(setParent);
         context = context.pop();
         return buffer;
    • summary
  • dojox.dtl.tag.loader.BlockNode.rendered

    • summary
  • dojox.dtl.tag.loader.BlockNode.context

    • summary
  • dojox.dtl.tag.loader.BlockNode.parent

    • summary
  • dojox.dtl.tag.loader.BlockNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return this.rendered.unrender(context, buffer);
    • summary
  • dojox.dtl.tag.loader.BlockNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.name, this.nodelist.clone(buffer));
    • summary
  • dojox.dtl.tag.loader.BlockNode.toString

    • type
      Function
    • source: [view]
        toString: function(){ return "dojox.dtl.tag.loader.BlockNode";
    • summary
  • dojox.dtl.tag.loader.ExtendsNode.getTemplate

    • summary
  • dojox.dtl.tag.loader.ExtendsNode.nodelist

    • summary
  • dojox.dtl.tag.loader.ExtendsNode.shared

    • summary
  • dojox.dtl.tag.loader.ExtendsNode.parent

    • summary
  • dojox.dtl.tag.loader.ExtendsNode.key

    • summary
  • dojox.dtl.tag.loader.ExtendsNode.parents

    • type
      Object
    • summary
  • dojox.dtl.tag.loader.ExtendsNode.getParent

    • type
      Function
    • parameters:
      • context: (typeof )
    • source: [view]
         var parent = this.parent;
         if(!parent){
          var string;
          parent = this.parent = context.get(this.key, false);
          if(!parent){
           throw new Error("extends tag used a variable that did not resolve");
          }
          if(typeof parent == "object"){
           var url = parent.url || parent.templatePath;
           if(parent.shared){
            this.shared = true;
           }
           if(url){
            parent = this.parent = url.toString();
           }else if(parent.templateString){
            // Allow the builder's string interning to work
            string = parent.templateString;
            parent = this.parent = " ";
           }else{
            parent = this.parent = this.parent.toString();
           }
          }
          if(parent && parent.indexOf("shared:") === 0){
           this.shared = true;
           parent = this.parent = parent.substring(7, parent.length);
          }
         }
         if(!parent){
          throw new Error("Invalid template name in 'extends' tag.");
         }
         if(parent.render){
          return parent;
         }
         if(this.parents[parent]){
          return this.parents[parent];
         }
         this.parent = this.getTemplate(string || dojox.dtl.text.getTemplateString(parent));
         if(this.shared){
          this.parents[parent] = this.parent;
         }
         return this.parent;
    • summary
  • dojox.dtl.tag.loader.ExtendsNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var parent = this.getParent(context);


         parent.blocks = parent.blocks || {};
         buffer.blocks = buffer.blocks || {};


         for(var i = 0, node; node = this.nodelist.contents[i]; i++){
          if(node instanceof dojox.dtl.tag.loader.BlockNode){
           var old = parent.blocks[node.name];
           if(old && old.nodelist != node.nodelist){
            // In a shared template, the individual blocks might change
            buffer = old.nodelist.unrender(context, buffer);
           }
           parent.blocks[node.name] = buffer.blocks[node.name] = {
            shared: this.shared,
            nodelist: node.nodelist,
            used: false
           }
          }
         }


         this.rendered = parent;
         return parent.nodelist.render(context, buffer, this);
    • summary
  • dojox.dtl.tag.loader.ExtendsNode.rendered

    • summary
  • dojox.dtl.tag.loader.ExtendsNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return this.rendered.unrender(context, buffer, this);
    • summary
  • dojox.dtl.tag.loader.ExtendsNode.toString

    • type
      Function
    • source: [view]
        toString: function(){ return "dojox.dtl.block.ExtendsNode";
    • summary
  • dojox.dtl.tag.loader.IncludeNode._path

    • summary
  • dojox.dtl.tag.loader.IncludeNode.constant

    • summary
  • dojox.dtl.tag.loader.IncludeNode.path

    • summary
  • dojox.dtl.tag.loader.IncludeNode.getTemplate

    • summary
  • dojox.dtl.tag.loader.IncludeNode.text

    • summary
  • dojox.dtl.tag.loader.IncludeNode.parsed

    • summary
  • dojox.dtl.tag.loader.IncludeNode._cache

    • summary
  • dojox.dtl.tag.loader.IncludeNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • 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;
    • summary
  • dojox.dtl.tag.loader.IncludeNode.last

    • summary
  • dojox.dtl.tag.loader.IncludeNode.rendered

    • summary
  • dojox.dtl.tag.loader.IncludeNode.nodelist

    • summary
  • dojox.dtl.tag.loader.IncludeNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         if(this.rendered){
          buffer = this.rendered.unrender(context, buffer);
         }
         if(this.nodelist){
          for(var i = 0, node; node = this.nodelist[i]; i++){
           buffer = buffer.remove(node);
          }
         }
         return buffer;
    • summary
  • dojox.dtl.tag.loader.IncludeNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this._path, this.constant, this.getTemplate, this.text.clone(buffer), this.parsed);
    • summary
  • dojox.dtl.tag.loader

    • type
      Object
    • summary
  • dojox.dtl.tag

    • type
      Object
    • summary
  • dojox.dtl

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary