public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException { TemplateModel nodeModelVariable = (TemplateModel) map.get("nodeModel"); if(nodeModelVariable == null) { throw new TemplateModelException("'nodeModel' variable not defined on 'serializer' directive."); } else if(nodeModelVariable instanceof NodeModel) { Element element = (Element) ((NodeModel)nodeModelVariable).getWrappedObject(); TemplateModel format = (TemplateModel) map.get("format"); if(format instanceof TemplateBooleanModel) { XmlUtil.serialize(element, ((TemplateBooleanModel)format).getAsBoolean(), environment.getOut()); } else { XmlUtil.serialize(element, false, environment.getOut()); } } else { throw new TemplateModelException("Invalid NodeModel variable reference. Not a NodeModel."); } } }
public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException { TemplateModel nodeModelVariable = (TemplateModel) map.get("nodeModel"); if(nodeModelVariable == null) { throw new TemplateModelException("'nodeModel' variable not defined on 'serializer' directive."); } else if(nodeModelVariable instanceof NodeModel) { Element element = (Element) ((NodeModel)nodeModelVariable).getWrappedObject(); TemplateModel format = (TemplateModel) map.get("format"); if(format instanceof TemplateBooleanModel) { XmlUtil.serialize(element, ((TemplateBooleanModel)format).getAsBoolean(), environment.getOut()); } else { XmlUtil.serialize(element, false, environment.getOut()); } } else { throw new TemplateModelException("Invalid NodeModel variable reference. Not a NodeModel."); } } }