private static STGroup readStringTemplateGroup(ClassLoader classLoader, String path) { try { URL resource = classLoader.getResource(path); STGroupFile group = new STGroupFile(resource, StandardCharsets.UTF_8.name(), '<', '>'); group.load(); return group; } catch (Exception e) { throw new RuntimeException("Unable to read StringTemplate group file at " + path + " on classpath", e); } } }
this.templateFile = new STGroupFile(this.url, "UTF-8", '<', '>'); this.templateFile.setListener(this.stErrorListener); this.templateFile.registerRenderer(String.class, new IntegerOrStringRenderer());
this.templateFile = new STGroupFile(this.url, "UTF-8", '<', '>'); this.templateFile.setListener(this.stErrorListener); this.templateFile.registerRenderer(String.class, new IntegerOrStringRenderer());
@Test(groups = "fast") public void testCheckQueries() throws Exception { final STGroup kombucha = new STGroupFile(this.getClass().getResource("/org/killbill/billing/util/dao/Kombucha.sql.stg"), "UTF-8", '<', '>');
public void loadDependencyTemplates() { if (templates != null) return; String fileName = "org/antlr/v4/tool/templates/depend.stg"; templates = new STGroupFile(fileName, "UTF-8"); }
public void loadDependencyTemplates() { if (templates != null) return; String fileName = "org/antlr/v4/tool/templates/depend.stg"; templates = new STGroupFile(fileName, "UTF-8"); }
public void loadDependencyTemplates() { if (templates != null) return; String fileName = "org/antlr/v4/tool/templates/depend.stg"; templates = new STGroupFile(fileName, "UTF-8"); }
public BuilderGenerator() { URL url = BuilderGenerator.class.getResource("/stringtemplates/builder-source.stg"); this.templateGroup = new STGroupFile(url, "UTF-8", '<', '>'); this.templateGroup.load(); if(!this.templateGroup.isDefined(SOURCE_TEMPLATE_NAME)) { throw new IllegalStateException("StringTemplate resource does not define 'builder_source' template"); } }
public boolean templatesExist() { String groupFileName = CodeGenerator.TEMPLATE_ROOT + "/" + getLanguage() + "/" + getLanguage() + STGroup.GROUP_FILE_EXTENSION; STGroup result = null; try { result = new STGroupFile(groupFileName); } catch (IllegalArgumentException iae) { result = null; } return result!=null; }
public boolean templatesExist() { String groupFileName = CodeGenerator.TEMPLATE_ROOT + "/" + getLanguage() + "/" + getLanguage() + STGroup.GROUP_FILE_EXTENSION; STGroup result = null; try { result = new STGroupFile(groupFileName); } catch (IllegalArgumentException iae) { result = null; } return result!=null; }
public static void test3() throws IOException { String templates = "main() ::= <<\n" + "Foo: <{bar};format=\"lower\">\n" + ">>\n"; String tmpdir = System.getProperty("java.io.tmpdir"); writeFile(tmpdir, "t.stg", templates); STGroup group = new STGroupFile(tmpdir+"/"+"t.stg"); ST st = group.getInstanceOf("main"); st.inspect(); }
public static void test3() throws IOException { String templates = "main() ::= <<\n" + "Foo: <{bar};format=\"lower\">\n" + ">>\n"; String tmpdir = System.getProperty("java.io.tmpdir"); writeFile(tmpdir, "t.stg", templates); STGroup group = new STGroupFile(tmpdir+"/"+"t.stg"); ST st = group.getInstanceOf("main"); st.inspect(); }
public static void test3() throws IOException { String templates = "main() ::= <<\n" + "Foo: <{bar};format=\"lower\">\n" + ">>\n"; String tmpdir = System.getProperty("java.io.tmpdir"); writeFile(tmpdir, "t.stg", templates); STGroup group = new STGroupFile(tmpdir+"/"+"t.stg"); ST st = group.getInstanceOf("main"); st.inspect(); }
public static void test3() throws IOException { String templates = "main() ::= <<\n" + "Foo: <{bar};format=\"lower\">\n" + ">>\n"; String tmpdir = System.getProperty("java.io.tmpdir"); writeFile(tmpdir, "t.stg", templates); STGroup group = new STGroupFile(tmpdir+"/"+"t.stg"); ST st = group.getInstanceOf("main"); st.inspect(); }
STGroup g = new STGroupFile("templates/emailTemplate.stg", '$', '$'); ST emailTemplate = g.getInstanceOf("html_format"); emailTemplate.add("keyToReplace1", "value for the first key"); emailTemplate.add("keyToReplace2", "value for the second key"); String result = emailTemplate.render();
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
public void loadPrecRuleTemplates() { String templateGroupFile = "org/antlr/v4/tool/templates/LeftRecursiveRules.stg"; recRuleTemplates = new STGroupFile(templateGroupFile); if ( !recRuleTemplates.isDefined("recRule") ) { tool.errMgr.toolError(ErrorType.MISSING_CODE_GEN_TEMPLATES, "LeftRecursiveRules"); } // use codegen to get correct language templates; that's it though CodeGenerator gen = new CodeGenerator(tool, null, language); codegenTemplates = gen.getTemplates(); }
@Test @Category(JDBITests.class) public void testFoo() throws Exception { final URL stg = ST4Test.class.getResource("st4behavior.stg"); final STGroup group = new STGroupFile(stg, "UTF-8", '<', '>'); final ST st = group.getInstanceOf("foo"); st.add("name", "Brian"); final String out = st.render(); assertThat(out).isEqualTo("hello (: Brian :)"); } }
public void execute() { STGroup targetGroup = new STGroupFile(runtimeTemplates.getPath()); targetGroup.registerModelAdaptor(STGroup.class, new STGroupModelAdaptor()); targetGroup.registerRenderer(String.class, new StringRenderer(), true); targetGroup.defineDictionary("escape", new JavaEscapeStringMap()); targetGroup.defineDictionary("lines", new LinesStringMap()); targetGroup.defineDictionary("strlen", new StrlenStringMap()); String rootFolder = "org/antlr/v4/test/runtime/templates"; generateCodeForFoldersInIndex(targetGroup, rootFolder); }