use of org.beetl.ext.tag.HTMLTagVarBindingWrapper in project beetl2.0 by javamonkey.
the class TagVarBindingStatement method runTag.
@Override
protected void runTag(Tag tag, Context ctx) {
try {
if (tag instanceof HTMLTagVarBindingWrapper) {
HTMLTagVarBindingWrapper htmlTag = (HTMLTagVarBindingWrapper) tag;
// 初始化
Object[] vars = htmlTag.bindVars();
if (vars != null) {
for (int i = 0; i < vars.length; i++) {
ctx.vars[varIndexs[i].getVarIndex()] = vars[i];
}
}
LinkedHashMap<String, Integer> indexMap = new LinkedHashMap<String, Integer>(this.varIndexs.length);
for (VarDefineNode node : this.varIndexs) {
indexMap.put(node.token.text, node.varIndex);
}
htmlTag.mapName2Index(indexMap);
} else {
BeetlException be = new BeetlException(BeetlException.ERROR, "tag必须是HTMLTagVarBindingWrapper");
be.pushToken(this.token);
throw be;
}
tag.render();
} catch (BeetlException ex) {
// BeetlException异常时不要设置token,因为抛出的地方已经设置了
throw ex;
} catch (RuntimeException ex) {
BeetlException be = new BeetlException(BeetlException.ERROR, "tag执行抛错", ex);
be.pushToken(token);
throw be;
}
}
Aggregations