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 File: TemplateVarsTest.java    From RetroFacebook with 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 File: TemplateVarsTest.java    From RetroFacebook with 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 File: TemplateVarsTest.java    From SimpleWeibo with 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
Source File: TemplateNodeView.java    From velocity-engine with Apache License 2.0 5 votes vote down vote up
/**
 * 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 File: VelocityWrapper.java    From consulo with 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);
}