public CompiledST defineTemplate(String templateName, String template) { try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
/** for testing */ public CompiledST defineTemplate(String templateName, String template) { if ( templateName.charAt(0)!='/' ) templateName = "/"+templateName; try { CompiledST impl = defineTemplate(templateName, new CommonToken(GroupParser.ID, templateName), null, template, null); return impl; } catch (STException se) { // we have reported the error; the exception just blasts us // out of parsing this template } return null; }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
public CompiledST defineTemplate(String name, String argsS, String template) { String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
/** for testing */ public CompiledST defineTemplate(String name, String argsS, String template) { if ( name.charAt(0)!='/' ) name = "/"+name; String[] args = argsS.split(","); List<FormalArgument> a = new ArrayList<FormalArgument>(); for (String arg : args) { a.add(new FormalArgument(arg)); } return defineTemplate(name, new CommonToken(GroupParser.ID, name), a, template, null); }
public void defineTemplateOrRegion( String fullyQualifiedTemplateName, String regionSurroundingTemplateName, Token templateToken, String template, Token nameToken, List<FormalArgument> args) { try { if ( regionSurroundingTemplateName!=null ) { defineRegion(regionSurroundingTemplateName, nameToken, template, templateToken); } else { defineTemplate(fullyQualifiedTemplateName, nameToken, args, template, templateToken); } } catch (STException e) { // after getting syntax error in a template, we emit msg // and throw exception to blast all the way out to here. } }
public void defineTemplateOrRegion( String fullyQualifiedTemplateName, String regionSurroundingTemplateName, Token templateToken, String template, Token nameToken, List<FormalArgument> args) { try { if ( regionSurroundingTemplateName!=null ) { defineRegion(regionSurroundingTemplateName, nameToken, template, templateToken); } else { defineTemplate(fullyQualifiedTemplateName, nameToken, args, template, templateToken); } } catch (STException e) { // after getting syntax error in a template, we emit msg // and throw exception to blast all the way out to here. } }
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"));
STGroup group = new STGroup('$', '$'); group.registerRenderer(...); CompiledST compiledTemplate = group.defineTemplate("name", ...); compiledTemplate.hasFormalArgs = false; // very important! // later on... ST template = group.getInstanceOf("name");