123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- if(!dojo._hasResource["dojox.dtl._Templated"]){
- dojo._hasResource["dojox.dtl._Templated"] = true;
- dojo.provide("dojox.dtl._Templated");
- dojo.require("dijit._Templated");
- dojo.require("dojox.dtl._base");
- dojo.declare("dojox.dtl._Templated", dijit._Templated, {
- _dijitTemplateCompat: false,
- buildRendering: function(){
- var node;
- if(this.domNode && !this._template){
- return;
- }
- if(!this._template){
- var t = this.getCachedTemplate(
- this.templatePath,
- this.templateString,
- this._skipNodeCache
- );
- if(t instanceof dojox.dtl.Template) {
- this._template = t;
- }else{
- node = t;
- }
- }
- if(!node){
- var context = new dojox.dtl._Context(this);
- if(!this._created){
- delete context._getter;
- }
- var nodes = dojo._toDom(
- this._template.render(context)
- );
-
- if(nodes.nodeType !== 1 && nodes.nodeType !== 3){
-
-
- for(var i = 0, l = nodes.childNodes.length; i < l; ++i){
- node = nodes.childNodes[i];
- if(node.nodeType == 1){
- break;
- }
- }
- }else{
-
- node = nodes;
- }
- }
- this._attachTemplateNodes(node);
- if(this.widgetsInTemplate){
-
-
- var parser = dojo.parser, qry, attr;
- if(parser._query != "[dojoType]"){
- qry = parser._query;
- attr = parser._attrName;
- parser._query = "[dojoType]";
- parser._attrName = "dojoType";
- }
-
- var cw = (this._startupWidgets = dojo.parser.parse(node, {
- noStart: !this._earlyTemplatedStartup,
- inherited: {dir: this.dir, lang: this.lang}
- }));
-
- if(qry){
- parser._query = qry;
- parser._attrName = attr;
- }
- this._supportingWidgets = dijit.findWidgets(node);
- this._attachTemplateNodes(cw, function(n,p){
- return n[p];
- });
- }
- if(this.domNode){
- dojo.place(node, this.domNode, "before");
- this.destroyDescendants();
- dojo.destroy(this.domNode);
- }
- this.domNode = node;
- this._fillContent(this.srcNodeRef);
- },
- _templateCache: {},
- getCachedTemplate: function(templatePath, templateString, alwaysUseString){
-
-
- var tmplts = this._templateCache;
- var key = templateString || templatePath;
- if(tmplts[key]){
- return tmplts[key];
- }
- templateString = dojo.string.trim(templateString || dojo.cache(templatePath, {sanitize: true}));
- if( this._dijitTemplateCompat &&
- (alwaysUseString || templateString.match(/\$\{([^\}]+)\}/g))
- ){
- templateString = this._stringRepl(templateString);
- }
-
- if(alwaysUseString || !templateString.match(/\{[{%]([^\}]+)[%}]\}/g)){
- return tmplts[key] = dojo._toDom(templateString);
- }else{
- return tmplts[key] = new dojox.dtl.Template(templateString);
- }
- },
- render: function(){
- this.buildRendering();
- },
- startup: function(){
- dojo.forEach(this._startupWidgets, function(w){
- if(w && !w._started && w.startup){
- w.startup();
- }
- });
- this.inherited(arguments);
- }
- });
- }
|