goja.mvc.render.ftl.layout.SuperDirective Maven / Gradle / Ivy
The newest version!
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013-2014 sagyf Yang. The Four Group.
*/
package goja.mvc.render.ftl.layout;
import goja.mvc.render.ftl.kit.DirectiveKit;
import goja.mvc.render.ftl.kit.TemplateDirectiveBodyOverrideWraper;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import java.io.IOException;
import java.util.Map;
/**
* .
*
* @author poplar.yfyang
* @version 1.0 2012-04-20 上午7:34
* @since JDK 1.5
*/
public class SuperDirective implements TemplateDirectiveModel {
public final static String DIRECTIVE_NAME = "super";
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env,
Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
TemplateDirectiveBodyOverrideWraper current =
(TemplateDirectiveBodyOverrideWraper) env.getVariable(DirectiveKit.OVERRIDE_CURRENT_NODE);
if (current == null) {
throw new TemplateException("<@super/> direction must be child of override", env);
}
TemplateDirectiveBody parent = current.parentBody;
if (parent == null) {
throw new TemplateException("not found parent for <@super/>", env);
}
parent.render(env.getOut());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy