dojox.dtl._HtmlParser.parse
dojo.require("dojox.dtl.html");
defined in dojox/dtl/html.js
Usage
function (/*Array?*/ stop_at) (view source)
var types = ddh.types; var terminators = {}; var tokens = this.contents; if(!stop_at){ stop_at = []; } for(var i = 0; i < stop_at.length; i++){ terminators[stop_at[i]] = true; } var nodelist = new dd._HtmlNodeList(); while(this.i < tokens.length){ var token = tokens[this.i++]; var type = token[0]; var value = token[1]; if(type == types.custom){ nodelist.push(value); }else if(type == types.change){ var changeNode = new dd.ChangeNode(value, token[2], token[3]); value[changeNode.attr] = changeNode; nodelist.push(changeNode); }else if(type == types.attr){ var fn = ddt.getTag("attr:" + token[2], true); if(fn && token[3]){ nodelist.push(fn(null, token[2] + " " + token[3])); }else if(dojo.isString(token[3]) && (token[3].indexOf("{%") != -1 || token[3].indexOf("{{") != -1)){ nodelist.push(new dd.AttributeNode(token[2], token[3])); } }else if(type == types.elem){ var fn = ddt.getTag("node:" + value.tagName.toLowerCase(), true); if(fn){ // TODO: We need to move this to tokenization so that it's before the // node and the parser can be passed here instead of null nodelist.push(fn(null, value, value.tagName.toLowerCase())); } nodelist.push(new dd._HtmlNode(value)); }else if(type == types.varr){ nodelist.push(new dd._HtmlVarNode(value)); }else if(type == types.text){ nodelist.push(new dd._HtmlTextNode(value.data || value)); }else if(type == types.tag){ if(terminators[value]){ --this.i; return nodelist; } var cmd = value.split(/\s+/g); if(cmd.length){ cmd = cmd[0]; var fn = ddt.getTag(cmd); if(typeof fn != "function"){ throw new Error("Function not found for " + cmd); } var tpl = fn(this, value); if(tpl){ nodelist.push(tpl); } } } } if(stop_at.length){ throw new Error("Could not find closing tag(s): " + stop_at.toString()); } return nodelist;
parameter | type | description |
---|---|---|
stop_at | Array | Optional. |