Exemplo n.º 1
0
  @Override
  public void execute(Context context, Writer writer, Object[] values) throws Exception {
    Object assign = values[1];
    if (assign != null) {
      writer = new StringWriter();
    }

    // 加载子模板, 设置子模板的父容器
    Template template = context.getTemplate();
    String name = template.getPath((String) values[0], true);

    template = template.getEngine().getTemplate(name);
    Context childContext = new Context(context);

    int len = values.length;
    for (int i = 2; i < len; i += 2) {
      childContext.set((String) values[i], values[i + 1]);
    }

    template.merge(childContext, writer);

    if (assign != null) {
      context.set((String) assign, writer.toString());
    }
  }
Exemplo n.º 2
0
 @Override
 public void scan(Template template) {
   super.scan(template);
   if (getParameter(2) != null) {
     template.preventCacheVariable(getParameter(2).toString());
   }
 }