Java Code Examples for org.apache.velocity.runtime.RuntimeSingleton#parse()

The following examples show how to use org.apache.velocity.runtime.RuntimeSingleton#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: RetroFacebook   File: TemplateVarsTest.java    License: Apache License 2.0 5 votes vote down vote up
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
 
Example 2
Source Project: RetroFacebook   File: TemplateVarsTest.java    License: Apache License 2.0 5 votes vote down vote up
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
 
Example 3
Source Project: SimpleWeibo   File: TemplateVarsTest.java    License: Apache License 2.0 5 votes vote down vote up
static SimpleNode parsedTemplateForString(String string) {
  try {
    Reader reader = new StringReader(string);
    return RuntimeSingleton.parse(reader, string);
  } catch (ParseException e) {
    throw new AssertionError(e);
  }
}
 
Example 4
/**
 * Default constructor: sets up the Velocity
 * Runtime, creates the visitor for traversing
 * the node structure and then produces the
 * visual representation by the visitation.
 */
public TemplateNodeView(String templateFile)
{
    try
    {
        RuntimeSingleton.init("velocity.properties");

        InputStreamReader isr = new InputStreamReader(
                                   new FileInputStream(templateFile),
                                   RuntimeSingleton.getString(RuntimeSingleton.INPUT_ENCODING));

        BufferedReader br = new BufferedReader( isr );

        Template tmpl = new Template();
        tmpl.setName(templateFile);
        document = RuntimeSingleton.parse( br, tmpl);

        visitor = new NodeViewMode();
        visitor.setContext(null);
        visitor.setWriter(new PrintWriter(System.out));
        document.jjtAccept(visitor, null);
    }
    catch (Exception e)
    {
        System.out.println(e);
        e.printStackTrace();
    }
}
 
Example 5
Source Project: consulo   File: VelocityWrapper.java    License: Apache License 2.0 4 votes vote down vote up
static SimpleNode parse(Reader reader, String templateName) throws ParseException {
  Template template = new Template();
  template.setName(templateName);
  return RuntimeSingleton.parse(reader, template);
}