0
我有一个用Dojo编写的基本小部件,它使用DTL来打印几个变量。但是,如果其中一个变量为空,则会导致错误(str为空)。有没有可能解决或绕过这个错误?我想它打印只是一个空字符串...在dojo中打印空值时出错dtl
我使用道场1.9.0在Firefox 24
我有一个用Dojo编写的基本小部件,它使用DTL来打印几个变量。但是,如果其中一个变量为空,则会导致错误(str为空)。有没有可能解决或绕过这个错误?我想它打印只是一个空字符串...在dojo中打印空值时出错dtl
我使用道场1.9.0在Firefox 24
我有同样的问题,我结束了创建一个补丁因此这将不会发生。 这将返回字符串null。如果你想让它返回空的sting取消注释str =“”;
//Patch for DTL so it wont fail everytime there is a null value in JSON.
require([ "dojox/dtl/_base"],function(){
dojox.dtl._VarNode.prototype.render = function(context, buffer){
var str = this.contents.resolve(context);
if(str){
if(!str.safe){
str = dojox.dtl._base.escape("" + str);
}
}else{
writeLog("=====Value was Null::" + this.contents.key);
//str="";
}
return buffer.concat(str);
};
});
欢迎来到StackOverflow。你有一些我们可以看到的代码吗?如果没有代码,我们很难帮助你。 – sircapsalot