Examples of STGroupString


Examples of org.stringtemplate.v4.STGroupString

      "  Ignore\n" +
      "  newlines and indents\n" +
      "<x>\n\n\n" +
      "<@end>\n" +
      "%>\n";
    STGroup g = new STGroupString(template);
    ST st = g.getInstanceOf("t");
    st.add("x", 99);
    String expected = "Ignorenewlines and indents99";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

      "<variables:{ v | <v.decl:(v.format)()>}; separator=\"\\n\">"+newline +
      ">>"+newline+
      "intdecl(decl) ::= \"int <decl.name> = 0;\""+newline +
      "intarray(decl) ::= \"int[] <decl.name> = null;\""+newline
      ;
    STGroup group = new STGroupString(templates);
    ST f = group.getInstanceOf("file");
    f.addAggr("variables.{ decl,format }", new Decl("i", "int"), "intdecl");
    f.addAggr("variables.{decl ,  format}", new Decl("a", "int-array"), "intarray");
    //System.out.println("f='"+f+"'");
    String expecting = "int i = 0;" +newline+
               "int[] a = null;";
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testPassThru() throws Exception {
    String templates =
      "a(x,y) ::= \"<b(...)>\"\n" +
      "b(x,y) ::= \"<x><y>\"\n";
    STGroup group = new STGroupString(templates);
    ST a = group.getInstanceOf("a");
    a.add("x", "x");
    a.add("y", "y");
    String expected = "xy";
    String result = a.render();
    assertEquals(expected, result);
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testPassThruWithDefaultValue() throws Exception {
    String templates =
      "a(x,y) ::= \"<b(...)>\"\n" + // should not set y when it sees "no value" from above
      "b(x,y={99}) ::= \"<x><y>\"\n";
    STGroup group = new STGroupString(templates);
    ST a = group.getInstanceOf("a");
    a.add("x", "x");
    String expected = "x99";
    String result = a.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testPassThruWithDefaultValueThatLacksDefinitionAbove() throws Exception {
    String templates =
      "a(x) ::= \"<b(...)>\"\n" + // should not set y when it sees "no definition" from above
      "b(x,y={99}) ::= \"<x><y>\"\n";
    STGroup group = new STGroupString(templates);
    ST a = group.getInstanceOf("a");
    a.add("x", "x");
    String expected = "x99";
    String result = a.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testPassThruPartialArgs() throws Exception {
    String templates =
      "a(x,y) ::= \"<b(y={99},...)>\"\n" +
      "b(x,y) ::= \"<x><y>\"\n";
    STGroup group = new STGroupString(templates);
    ST a = group.getInstanceOf("a");
    a.add("x", "x");
    a.add("y", "y");
    String expected = "x99";
    String result = a.render();
    assertEquals(expected, result);
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testPassThruNoMissingArgs() throws Exception {
    String templates =
      "a(x,y) ::= \"<b(y={99},x={1},...)>\"\n" +
      "b(x,y) ::= \"<x><y>\"\n";
    STGroup group = new STGroupString(templates);
    ST a = group.getInstanceOf("a");
    a.add("x", "x");
    a.add("y", "y");
    String expected = "199";
    String result = a.render();
    assertEquals(expected, result);
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

    String Sub =
      "t() ::= <<\n" +
      "<d.a>\n" +
      ">>\n";
    STGroup r = new STGroupString(Root);
    STGroup s = new STGroupString(Sub);
    s.importTemplates(r);
    ST st = s.getInstanceOf("t"); // visible only if we can see inherited dicts
    String expected = "b";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  @Test public void testTrimmedNewlinesBeforeAfterInTemplate() throws Exception {
    String templates =
      "a(x) ::= <<"+newline+
      "foo"+newline+
      ">>"+newline;
    STGroupString group = new STGroupString(templates);
    ST st = group.getInstanceOf("a");
    String expected = "foo";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupString

  }

  @Test public void testDontTrimJustSpaceBeforeAfterInTemplate() throws Exception {
    String templates =
      "a(x) ::= << foo >>\n";
    STGroupString group = new STGroupString(templates);
    ST st = group.getInstanceOf("a");
    String expected = " foo ";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.