@Test public void testSimple() throws SAXException, IOException { GroovyTemplateProcessor processor = new GroovyTemplateProcessor(); Source template = new StringSource("<a>$value</a>"); Source result = processor.processTemplate(template, null, singletonMap("value", (Object)"test")); assertXMLEqual("<a>test</a>", serialize(result)); }
public Source processTemplate(Source template, Source input, Map<String, Object> parameters) { try { String templateText = serialize(template); HashMap<String, Object> binding = new HashMap<String, Object> (parameters); if (input!=null) { Document inputDocument = loadDocument(input); binding.put(inputDocument.getFirstChild().getLocalName(), new XmlSlurper().parse(new StringReader(serialize(inputDocument)))); } binding.put("IGNORE", "${IGNORE}"); return new StringSource(templateEngine.createTemplate(templateText).make(binding).toString()); } catch (Exception e) { throw new IllegalArgumentException("Can not process Groovy template.",e); } }
GroovyTemplateProcessor implements TemplateProcessor { public Source processTemplate(Source template, Source input, Map<String, Object> parameters) { try { String templateText = serialize(template); HashMap<String, Object> binding = new HashMap<String, Object> (parameters); if (input!=null) { Document inputDocument = loadDocument(input); binding.put(inputDocument.getFirstChild().getLocalName(), new XmlSlurper().parse(new StringReader(serialize(inputDocument)))); } binding.put("IGNORE", "${IGNORE}"); return new StringSource(templateEngine.createTemplate(templateText).make(binding).toString()); } catch (Exception e) { throw new IllegalArgumentException("Can not process Groovy template.",e); } } }
GroovyTemplateProcessor implements TemplateProcessor { public Source processTemplate(Source template, Source input, Map<String, Object> parameters) { try { String templateText = serialize(template); HashMap<String, Object> binding = new HashMap<String, Object> (parameters); if (input!=null) { Document inputDocument = loadDocument(input); binding.put(inputDocument.getFirstChild().getLocalName(), new XmlSlurper().parse(new StringReader(serialize(inputDocument)))); } binding.put("IGNORE", "${IGNORE}"); return new StringSource(templateEngine.createTemplate(templateText).make(binding).toString()); } catch (Exception e) { throw new IllegalArgumentException("Can not process Groovy template.",e); } } GroovyTemplateProcessor(TemplateEngine templateEngine);  GroovyTemplateProcessor(); }
GroovyTemplateProcessor implements TemplateProcessor { public Source processTemplate(Source template, Source input, Map<String, Object> parameters) { try { String templateText = serialize(template); HashMap<String, Object> binding = new HashMap<String, Object> (parameters); if (input!=null) { Document inputDocument = loadDocument(input); binding.put(inputDocument.getFirstChild().getLocalName(), new XmlSlurper().parse(new StringReader(serialize(inputDocument)))); } binding.put("IGNORE", "${IGNORE}"); return new StringSource(templateEngine.createTemplate(templateText).make(binding).toString()); } catch (Exception e) { throw new IllegalArgumentException("Can not process Groovy template.",e); } } GroovyTemplateProcessor(TemplateEngine templateEngine);  GroovyTemplateProcessor(); Source processTemplate(Source template, Source input, Map<String, Object> parameters); }
GroovyTemplateProcessor implements TemplateProcessor { public Source processTemplate(Source template, Source input, Map<String, Object> parameters) { try { String templateText = serialize(template); HashMap<String, Object> binding = new HashMap<String, Object> (parameters); if (input!=null) { Document inputDocument = loadDocument(input); binding.put(inputDocument.getFirstChild().getLocalName(), new XmlSlurper().parse(new StringReader(serialize(inputDocument)))); } binding.put("IGNORE", "${IGNORE}"); return new StringSource(templateEngine.createTemplate(templateText).make(binding).toString()); } catch (Exception e) { throw new IllegalArgumentException("Can not process Groovy template.",e); } } GroovyTemplateProcessor(TemplateEngine templateEngine);  GroovyTemplateProcessor(); Source processTemplate(Source template, Source input, Map<String, Object> parameters);  }