@Override public SimpleNode parse(Reader reader, String templateName, boolean dumpNamespace) throws ParseException { SimpleNode node = super.parse(reader, templateName, dumpNamespace); if (interpolationHack) { node = traversNode(node); } return node; }
@Override public SimpleNode parse(Reader reader, String templateName, boolean dumpNamespace) throws ParseException { SimpleNode node = super.parse(reader, templateName, dumpNamespace); if (interpolationHack) { node = traversNode(node); } return node; }
/** * Parse the input and return the root of the AST node structure. * * @param InputStream inputstream retrieved by a resource loader * @param String name of the template being parsed * @param dumpNamespace flag to dump the Velocimacro namespace for this template */ public static SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace ) throws ParseException { return ri.parse( reader, templateName, dumpNamespace ); }
/** * Parse the input and return the root of the AST node structure. * * @param reader Reader retrieved by a resource loader * @param templateName name of the template being parsed * @param dumpNamespace flag to dump the Velocimacro namespace for this template * @return A root node representing the template as an AST tree. * @throws ParseException When the template could not be parsed. * @see RuntimeInstance#parse(Reader, String, boolean) */ public static SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace ) throws ParseException { return ri.parse( reader, templateName, dumpNamespace ); }
/** * Parse the input and return the root of the AST node structure. * * @param reader Reader retrieved by a resource loader * @param templateName name of the template being parsed * @param dumpNamespace flag to dump the Velocimacro namespace for this template * @return A root node representing the template as an AST tree. * @throws ParseException When the template could not be parsed. * @see RuntimeInstance#parse(Reader, String, boolean) */ public static SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace ) throws ParseException { return ri.parse( reader, templateName, dumpNamespace ); }
/** * Parse the input and return the root of * AST node structure. * <br><br> * In the event that it runs out of parsers in the * pool, it will create and let them be GC'd * dynamically, logging that it has to do that. This * is considered an exceptional condition. It is * expected that the user will set the * PARSER_POOL_SIZE property appropriately for their * application. We will revisit this. * * @param InputStream inputstream retrieved by a resource loader * @param String name of the template being parsed */ public static SimpleNode parse( Reader reader, String templateName ) throws ParseException { return ri.parse( reader, templateName ); }
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) { try { return velocityRuntimeInstance.parse(templateStr, resourceName); } catch (ParseException e) { throw new AssertionError(e); } }
/** * Parse the input and return the root of * AST node structure. * <br><br> * In the event that it runs out of parsers in the * pool, it will create and let them be GC'd * dynamically, logging that it has to do that. This * is considered an exceptional condition. It is * expected that the user will set the * PARSER_POOL_SIZE property appropriately for their * application. We will revisit this. * * @param reader Reader retrieved by a resource loader * @param template Template being parsed * @return A root node representing the template as an AST tree. * @throws ParseException When the template could not be parsed. * @see RuntimeInstance#parse(Reader, Template) */ public static SimpleNode parse( Reader reader, Template template ) throws ParseException { return ri.parse(reader, template); }
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) { try { return velocityRuntimeInstance.parse(templateStr, resourceName); } catch (ParseException e) { throw new AssertionError(e); } }
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) { try { return velocityRuntimeInstance.parse(templateStr, resourceName); } catch (ParseException e) { throw new AssertionError(e); } }
static SimpleNode parsedTemplateForResource(String templateStr, String resourceName) { try { return velocityRuntimeInstance.parse(templateStr, resourceName); } catch (ParseException e) { throw new AssertionError(e); } }
/** * Parse the input and return the root of * AST node structure. * <br><br> * In the event that it runs out of parsers in the * pool, it will create and let them be GC'd * dynamically, logging that it has to do that. This * is considered an exceptional condition. It is * expected that the user will set the * PARSER_POOL_SIZE property appropriately for their * application. We will revisit this. * * @param string String to be parsed * @param templateName name of the template being parsed * @return A root node representing the template as an AST tree. * @throws ParseException When the string could not be parsed as a template. * @since 1.6 */ public SimpleNode parse(String string, String templateName) throws ParseException { return parse(new StringReader(string), templateName); }
static SimpleNode parsedTemplateForResource(String resourceName) { InputStream in = RetroFacebookTemplateVars.class.getResourceAsStream(resourceName); if (in == null) { throw new IllegalArgumentException("Could not find resource: " + resourceName); } try { Reader reader = new InputStreamReader(in, "UTF-8"); return velocityRuntimeInstance.parse(reader, resourceName); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } catch (ParseException e) { throw new AssertionError(e); } }
static SimpleNode parsedTemplateForResource(String resourceName) { InputStream in = RetroWeiboTemplateVars.class.getResourceAsStream(resourceName); if (in == null) { throw new IllegalArgumentException("Could not find resource: " + resourceName); } try { Reader reader = new InputStreamReader(in, "UTF-8"); return velocityRuntimeInstance.parse(reader, resourceName); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } catch (ParseException e) { throw new AssertionError(e); } }
static SimpleNode parsedTemplateForResource(String resourceName) { InputStream in = RetroFacebookTemplateVars.class.getResourceAsStream(resourceName); if (in == null) { throw new IllegalArgumentException("Could not find resource: " + resourceName); } try { Reader reader = new InputStreamReader(in, "UTF-8"); return velocityRuntimeInstance.parse(reader, resourceName); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } catch (ParseException e) { throw new AssertionError(e); } }
static SimpleNode parsedTemplateForResource(String resourceName) { InputStream in = AutoJsonTemplateVars.class.getResourceAsStream(resourceName); if (in == null) { throw new IllegalArgumentException("Could not find resource: " + resourceName); } try { Reader reader = new InputStreamReader(in, "UTF-8"); return velocityRuntimeInstance.parse(reader, resourceName); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } catch (ParseException e) { throw new AssertionError(e); } }
@Override public SimpleNode parse(Reader reader, String templateName, boolean dumpNamespace) throws ParseException { SimpleNode node = super.parse(reader, templateName, dumpNamespace); if (interpolationHack) { node = traversNode(node); } return node; }
RuntimeInstance ri = new RuntimeInstance(); SimpleNode node = ri.parse( reader, "templateName" );
private SimpleNode parse(String template) { SimpleNode nodeTree; try { nodeTree = velocityRuntime.parse(new StringReader(template), template); } catch (ParseException pex) { throw new CayenneRuntimeException("Error parsing template '%s' : %s", template, pex.getMessage()); } if (nodeTree == null) { throw new CayenneRuntimeException("Error parsing template %s", template); } return nodeTree; } }
RuntimeInstance runtimeInstance = new RuntimeInstance(); runtimeInstance.init(); SimpleNode simpleNode = runtimeInstance.parse(reader, "nameOfYourTemplateResource"); Template template = new Template(); simpleNode.init(new InternalContextAdapterImpl(new VelocityContext()), runtimeInstance); template.setData(simpleNode); template.merge(...); ...