@Override public String render(String sql, StatementContext ctx) { ST template = new ST(new STGroup(), sql); ctx.getAttributes().forEach(template::add); return template.render(); } }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter STGroup.defaultGroup. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
private void createStGroup() { if (stgroup == null) { this.stgroup = new STGroup('<', '>'); } }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** Create ST using non-default delimiters; each one of these will live * in it's own group since you're overriding a default; don't want to * alter {@link STGroup#defaultGroup}. */ public ST(String template, char delimiterStartChar, char delimiterStopChar) { this(new STGroup(delimiterStartChar, delimiterStopChar), template); }
/** * @see LogWindowDockFactory#create() */ @Inject LogWindowDock() { this.columnNames = new ArrayList<Object>(4); this.group = new STGroup(); }
/** * @see StatusBarFactory#create() */ @Inject @OnAwt StatusBar(UiStatusPanel panel) { this.panel = panel; this.group = new STGroup(); this.workerExecuted = false; }
/** * Create a statement locator intended for setting on a DBI or Handle instance which will * lookup a template group to use based on the name of the sql object type for a particular query, using * the same logic as {@link UseST4StatementLocator}. */ public static StatementLocator perType(final UseSTGroupCache useCache) { return perType(useCache, new STGroup('<', '>')); }
protected STGroup getTemplateGroupFromFile(String fileName) throws IOException { final URL resourceUrl = Resources.getResource(this.getClass(), "/templates/" + fileName); STGroup stg = new STGroup(); stg.errMgr = new ErrorManager(ERROR_LISTENER); stg.loadGroupFile("", resourceUrl.toExternalForm()); return stg; }
/** * Retrieve screens template group * * @return Partials template group */ @Bean public STGroup screensTemplateGroup() { STGroup group = new STGroup('$', '$'); for (String path : getPaths("screen/templates.stg")) { group.loadGroupFile("", path); } return group; }
/** * Retrieve elements template group * * @return Partials template group */ @Bean public STGroup elementsTemplateGroup() { STGroup group = new STGroup('$', '$'); for (String path : getPaths("screen/elements.stg")) { group.loadGroupFile("", path); } return group; }
/** * Retrieve help template group * * @return Partials template group */ @Bean public STGroup helpTemplateGroup() { STGroup group = new STGroup('$', '$'); for (String path : getPaths("screen/help.stg")) { group.loadGroupFile("", path); } return group; }
STGroup myGroup = new STGroup(); myGroup.registerRenderer(Thing.class, new ThingRenderer()); ST myST = new ST(myGroup, "Hello, <thing>!"); myST.add("thing", new Thing()); return myST.render();
STGroup group = new STGroup('$', '$'); group.registerRenderer(...); CompiledST compiledTemplate = group.defineTemplate("name", ...); compiledTemplate.hasFormalArgs = false; // very important! // later on... ST template = group.getInstanceOf("name");
STGroup grp = new STGroup('$', '$'); final CompiledST templateA = grp.defineTemplate("a", "<li>$it.fname$ $it.lname$</li>"); templateA.addArg(new FormalArgument("it")); final CompiledST templateB = grp.defineTemplate("b", "<ul>$list:a()$</ul>"); templateB.addArg(new FormalArgument("list"));