Roo/Template.js
authorAlan Knowles <alan@akbkhome.com>
Tue, 27 Jul 2010 02:54:18 +0000 (10:54 +0800)
committerAlan Knowles <alan@akbkhome.com>
Tue, 27 Jul 2010 02:54:18 +0000 (10:54 +0800)
Roo/Template.js

index 281628c..12252cd 100644 (file)
@@ -43,36 +43,42 @@ Roo.Template.prototype = {
      * @return {String} The HTML fragment
      */
     applyTemplate : function(values){
-        if(this.compiled){
-            return this.compiled(values);
-        }
-        var useF = this.disableFormats !== true;
-        var fm = Roo.util.Format, tpl = this;
-        var fn = function(m, name, format, args){
-            if(format && useF){
-                if(format.substr(0, 5) == "this."){
-                    return tpl.call(format.substr(5), values[name], values);
-                }else{
-                    if(args){
-                        // quoted values are required for strings in compiled templates, 
-                        // but for non compiled we need to strip them
-                        // quoted reversed for jsmin
-                        var re = /^\s*['"](.*)["']\s*$/;
-                        args = args.split(',');
-                        for(var i = 0, len = args.length; i < len; i++){
-                            args[i] = args[i].replace(re, "$1");
-                        }
-                        args = [values[name]].concat(args);
+        try {
+            
+            if(this.compiled){
+                return this.compiled(values);
+            }
+            var useF = this.disableFormats !== true;
+            var fm = Roo.util.Format, tpl = this;
+            var fn = function(m, name, format, args){
+                if(format && useF){
+                    if(format.substr(0, 5) == "this."){
+                        return tpl.call(format.substr(5), values[name], values);
                     }else{
-                        args = [values[name]];
+                        if(args){
+                            // quoted values are required for strings in compiled templates, 
+                            // but for non compiled we need to strip them
+                            // quoted reversed for jsmin
+                            var re = /^\s*['"](.*)["']\s*$/;
+                            args = args.split(',');
+                            for(var i = 0, len = args.length; i < len; i++){
+                                args[i] = args[i].replace(re, "$1");
+                            }
+                            args = [values[name]].concat(args);
+                        }else{
+                            args = [values[name]];
+                        }
+                        return fm[format].apply(fm, args);
                     }
-                    return fm[format].apply(fm, args);
+                }else{
+                    return values[name] !== undefined ? values[name] : "";
                 }
-            }else{
-                return values[name] !== undefined ? values[name] : "";
-            }
-        };
-        return this.html.replace(this.re, fn);
+            };
+            return this.html.replace(this.re, fn);
+        } catch (e) {
+            console && console.log && console.log(e.toString());
+        }
+        return '';
     },
     
     /**