方法一:用Enjoy模板里的原样输出.#[[
{{# if(d.status == 1){ }}
]]#
正常
#[[
{{# } else { }}
]]#
禁用
#[[
{{# } }}
]]#
方法二:自定义laytpl指令@Override
public void onRender(Env env, Scope scope, Writer writer) {
if (exprList.length() > 1) {
throw new ParseException("Wrong number parameter of #date directive, one parameters allowed at most", location);
}
String expr = "";
if(exprList.length() > 0) {
expr = getParam(0, scope);
}
write(writer, " {{"+expr);
stat.exec(env, scope, writer);
write(writer, "}}");
}
@Override
public boolean hasEnd() {
return true;
}#laytpl('#') if(d.status == 1){ #end
正常
#laytpl('#') } else { #end
禁用
#laytpl('#') } #end
好像也没方便多少... 不知道有没有更好的办法.