コード例 #1
0
 public void doRender(Context context, String directiveName, Object param, List innerElements)
     throws Exception {
   long beginTime = System.currentTimeMillis();
   DirectiveUtils.renderAll(innerElements, context);
   Long value = new Long(System.currentTimeMillis() - beginTime);
   if (param instanceof String) {
     context.getParentLocalContext().putVariable((String) param, value);
   } else if (param instanceof NamePair) {
     VariableScopeUtils.putVariable(context, true, (NamePair) param, value);
   } else {
     Assert.fail("$block指令参数错误, 参数示例: $block{xxx} 或者 $block{global -> xxx}"); // TODO 未国际化
   }
 }
コード例 #2
0
 public void doRender(Context context, String directiveName, Object param) throws Exception {
   if (param instanceof Entry) {
     Entry model = (Entry) param;
     Object key = model.getKey();
     List list = (List) model.getValue();
     Object value = new Cycle(list);
     if (key instanceof NamePair) {
       VariableScopeUtils.putVariable(context, false, (NamePair) key, value);
     } else {
       String var = String.valueOf(key);
       context.putVariable(var, value);
     }
   } else {
     throw new IllegalStateException("$cycle指令参数错误!"); // TODO 未国际化
   }
 }