</code></pre>
* The tpl tag:
<pre><code>
- <div roo-for="a_variable or condition.."></tpl>
- <tpl roo-if="a_variable or condition"></tpl>
- <tpl roo-exec="some javascript"></tpl>
- <tpl roo-name="named_template"></tpl>
+ <div roo-for="a_variable or condition.."></div>
+ <div roo-if="a_variable or condition"></div>
+ <div roo-exec="some javascript"></div>
+ <div roo-name="named_template"></div>
</code></pre>
*
Roo.DomTemplate = function()
{
Roo.DomTemplate.superclass.constructor.apply(this, arguments);
- if (this.html) {
+ if (this.html) {
this.compile();
- }
+ }
};
* x.t:(test,tesT)
*
*/
- re : /\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
-
+ re : /(\{|\%7B)([\w-\.]+)(?:\:([\w\.]*)(?:\(([^)]*?)?\))?)?(\}|\%7D)/g,
+ //re : /\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
iterChild : function (node, method) {
var s = this.html;
// covert the html into DOM...
+ var doc = false;
+ var div =false;
+ try {
+ doc = document.implementation.createHTMLDocument("");
+ doc.documentElement.innerHTML = this.html ;
+ div = doc.documentElement;
+ } catch (e) {
+ // old IE... - nasty -- it causes all sorts of issues.. with
+ // images getting pulled from server..
+ div = document.createElement('div');
+ div.innerHTML = this.html;
+ }
+ //doc.documentElement.innerHTML = htmlBody
+
- var div = document.createElement('div');
- div.innerHTML = this.html ;
this.tpls = [];
var _t = this;
// create a top level template from the snippet..
- Roo.log(div.innerHTML);
+ //Roo.log(div.innerHTML);
var tpl = {
uid : 'master',
}
// parent now sees '{domtplXXXX}
- this.iterChild(node,this.compileNode)
+ this.iterChild(node,this.compileNode);
// we should now have node body...
var div = document.createElement('div');
div.appendChild(node);
tpl.dom = node;
+ // this has the unfortunate side effect of converting tagged attributes
+ // eg. href="{...}" into %7C...%7D
+ // this has been fixed by searching for those combo's although it's a bit hacky..
+
+
tpl.body = div.innerHTML;
},
+
+
+
+
/**
* Compile a segment of the template into a 'sub-template'
+ *
+ *
*
*
*/
{
var fm = Roo.util.Format;
var useF = this.disableFormats !== true;
+
var sep = Roo.isGecko ? "+\n" : ",\n";
+
var undef = function(str) {
- Roo.log("Property not found :" + str);
+ Roo.debug && Roo.log("Property not found :" + str);
return '';
};
+
+ //Roo.log(tpl.body);
+
+
- var fn = function(m, name, format, args)
+ var fn = function(m, lbrace, name, format, args)
{
+ //Roo.log("ARGS");
//Roo.log(arguments);
args = args ? args.replace(/\\'/g,"'") : args;
//["{TEST:(a,b,c)}", "TEST", "", "a,b,c", 0, "{TEST:(a,b,c)}"]
if (typeof(format) == 'undefined') {
- format= 'htmlEncode';
+ format = 'htmlEncode';
}
if (format == 'raw' ) {
format = false;
return "'"+ sep + udef_st + format + name + args + "))"+sep+"'";
}
- if (args.length) {
+ if (args && args.length) {
// called with xxyx.yuu:(test,test)
// change to ()
return "'"+ sep + udef_st + name + '(' + args + "))"+sep+"'";
try {
if(t.ifCall && !t.ifCall.call(this, values, parent)){
- Roo.log('if call on ' + t.value + ' return false');
+ Roo.debug && Roo.log('if call on ' + t.value + ' return false');
return '';
}
} catch(e) {
});
-Roo.XTemplate.from = function(el){
+Roo.DomTemplate.from = function(el){
el = Roo.getDom(el);
- return new Roo.XTemplate(el.value || el.innerHTML);
+ return new Roo.Domtemplate(el.value || el.innerHTML);
};
\ No newline at end of file