@Override protected void loadTemplate(SmooksResourceConfiguration config) throws IOException { String path = config.getResource(); if(path.charAt(0) == '/') { path = path.substring(1); } String dir = path.substring(0, path.lastIndexOf('/')); templateName = path.substring(path.lastIndexOf('/'), path.indexOf(".st")); templateGroupDir = new STRawGroupDir(dir, getEncoding().displayName(),'$','$'); template = templateGroupDir.getInstanceOf(templateName); }
@Override protected void loadTemplate(SmooksResourceConfiguration config) throws IOException { String path = config.getResource(); if(path.charAt(0) == '/') { path = path.substring(1); } String dir = path.substring(0, path.lastIndexOf('/')); templateName = path.substring(path.lastIndexOf('/'), path.indexOf(".st")); templateGroupDir = new STRawGroupDir(dir, getEncoding().displayName(),'$','$'); template = templateGroupDir.getInstanceOf(templateName); }
@Override protected void visit(Element element, ExecutionContext executionContext) { // First thing we do is clone the template for this transformation... // Commented out as due to https://github.com/antlr/stringtemplate4/issues/100 // ST transform = new ST(template); ST transform = templateGroupDir.getInstanceOf(templateName); Map<String, Object> beans = executionContext.getBeanContext().getBeanMap(); // Set the document data beans on the template and apply it... for (Map.Entry<String, Object> entry : beans.entrySet()) { transform.add(entry.getKey(), entry.getValue()); } String templatingResult = transform.render().trim(); Node resultNode = TextSerializationUnit.createTextElement(element, templatingResult); // Process the templating action, supplying the templating result... processTemplateAction(element, resultNode, executionContext); }
@Override protected void visit(Element element, ExecutionContext executionContext) { // First thing we do is clone the template for this transformation... // Commented out as due to https://github.com/antlr/stringtemplate4/issues/100 // ST transform = new ST(template); ST transform = templateGroupDir.getInstanceOf(templateName); Map<String, Object> beans = executionContext.getBeanContext().getBeanMap(); // Set the document data beans on the template and apply it... for (Map.Entry<String, Object> entry : beans.entrySet()) { transform.add(entry.getKey(), entry.getValue()); } String templatingResult = transform.render().trim(); Node resultNode = TextSerializationUnit.createTextElement(element, templatingResult); // Process the templating action, supplying the templating result... processTemplateAction(element, resultNode, executionContext); }