-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_InlineTemplateMixin.js
30 lines (28 loc) · 1005 Bytes
/
_InlineTemplateMixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/has"
], function(declare, lang, has){
has.add("dom-qsa", !!document.createElement("div").querySelectorAll);
return declare("dojox.mvc._InlineTemplateMixin", null, {
// summary:
// A mixin for template widget, which will look for `<script type="dojox/mvc/InlineTemplate">`
// and treat the HTML in there as the template string.
buildRendering: function(){
var root = this.srcNodeRef;
if(root){
var nodes = has("dom-qsa") ? root.querySelectorAll("script[type='dojox/mvc/InlineTemplate']") : root.getElementsByTagName("script"),
templates = [];
for(var i = 0, l = nodes.length; i < l; ++i){
if(!has("dom-qsa") && nodes[i].getAttribute("type") != "dojox/mvc/InlineTemplate"){ continue; }
templates.push(nodes[i].innerHTML);
}
var templateString = lang.trim(templates.join(""));
if(templateString){
this.templateString = templateString;
}
}
this.inherited(arguments);
}
});
});