0
我尝试修改代码生成的vsl文件,以检查是否实际输入了foreach循环,并且完全执行初始化代码。我尝试类似java的.length> 0但不起作用:
myMethod() {
#if (${reference.attributes}.length > 0)
[some init code]
#foreach ($attribute in ${reference.attributes})
#some_macro($attribute)
#end
[some other code related to stuff created in the
#end
}
什么是正确的方法?
谢谢。
如果我正确理解你的问题,你只需要运行一次init代码。您可以在init中设置变量并检查是否已经设置。像这样 #if($ foo!=“bar”) #set($ foo =“bar”) //在这里做init #end – SirVaulterScoff