2017-03-02 17:21
@gaurder 用自定义指令
代码如下
public class Money extends Directive{
@Override
public void exec(Env env, Scope scope, Writer writer) {
DecimalFormat df = new DecimalFormat("#.00");
Object value = exprList.eval(scope);
if (value != null) {
value = df.format(value);
write(writer, value.toString());
}
}
}
me.addDirective("money", new Money());
#money(price)