Examples of STGroup


Examples of org.stringtemplate.v4.STGroup

    String dir = getRandomDir();
    writeFile(dir, "GenerateHtml.stg", groupFile);
    writeFile(dir, "html.st", htmlFile);

    STGroup group = new STGroupFile(dir + "/GenerateHtml.stg", '<', '>');

    // test html template directly
    ST st = group.getInstanceOf("html");
    Assert.assertNotNull(st);
    String expected = "<table style=\"stuff\">";
    String result = st.render();
    assertEquals(expected, result);

    // test from entry template
    st = group.getInstanceOf("entry");
    Assert.assertNotNull(st);
    expected = "<table style=\"stuff\">";
    result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

    String dir = getRandomDir();
    writeFile(dir, "GenerateHtml.stg", groupFile);
    writeFile(dir, "HtmlTemplates.stg", htmlFile);

    STGroup group = new STGroupFile(dir + "/GenerateHtml.stg");

    // test html template directly
    ST st = group.getInstanceOf("html");
    Assert.assertNotNull(st);
    String expected = "<table style=\"stuff\">";
    String result = st.render();
    assertEquals(expected, result);

    // test from entry template
    st = group.getInstanceOf("entry");
    Assert.assertNotNull(st);
    expected = "<table style=\"stuff\">";
    result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

        "list(a,b) ::= <<" +
        "  <a><b>"+newline+
        ">>"+newline;

    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST t = group.getInstanceOf("list");
    t.impl.dump();
    t.add("a", "Terence");
    t.add("b", "Jim");
    String expecting =
        "  TerenceJim";
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

        "list(names) ::= <<" +
        "  <names; separator=\"\\n\">"+newline+
        ">>"+newline;

    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST t = group.getInstanceOf("list");
    t.add("names", "Terence");
    t.add("names", "Jim");
    t.add("names", "Sriram");
    String expecting =
        "  Terence"+newline+
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

    String templates =
        "list(names) ::= <<" +
        "  <names; separator=\"\n\">"+newline+
        ">>"+newline;
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST t = group.getInstanceOf("list");
    t.add("names", "Terence\nis\na\nmaniac");
    t.add("names", "Jim");
    t.add("names", "Sriram\nis\ncool");
    String expecting =
        "  Terence"+newline+
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

    String templates =
        "list(names) ::= <<" +
        "  <names>"+newline+
        ">>"+newline;
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST t = group.getInstanceOf("list");
    t.add("names", "Terence\n\nis a maniac");
    String expecting =
        "  Terence"+newline+
        ""+newline+ // no indent on blank line
        "  is a maniac";
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

        "Before:"+newline +
        "  <names; separator=\"\\n\">"+newline+
        "after" +newline+
        ">>"+newline;
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST t = group.getInstanceOf("list");
    t.add("names", "Terence");
    t.add("names", "Jim");
    t.add("names", "Sriram");
    String expecting =
        "Before:" +newline+
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

        "}" +
        ">>"+newline +
        "assign(lhs,expr) ::= \"<lhs>=<expr>;\""+newline
        ;
    writeFile(tmpdir, "t.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    ST t = group.getInstanceOf("method");
    t.add("name", "foo");
    ST s1 = group.getInstanceOf("assign");
    s1.add("lhs", "x");
    s1.add("expr", "0");
    ST s2 = group.getInstanceOf("ifstat");
    s2.add("expr", "x>0");
    ST s2a = group.getInstanceOf("assign");
    s2a.add("lhs", "y");
    s2a.add("expr", "x+y");
    ST s2b = group.getInstanceOf("assign");
    s2b.add("lhs", "z");
    s2b.add("expr", "4");
    s2.add("stats", s2a);
    s2.add("stats", s2b);
    t.add("stats", s1);
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

    String result = t.render();
    assertEquals(expecting, result);
  }

  @Test public void testIndentedIFWithNewlineBeforeText() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("t", "x",
      "begin"+newline+
      "    <if(x)>\n" +
      "foo\n" // no indent; ignore IF indent
      "    <endif>"+newline+    // ignore indent on if-tags on line by themselves
      "end"+newline);
    ST t = group.getInstanceOf("t");
    t.add("x", "x");
    String expecting="begin"+newline+"foo"+newline+"end";
    String result = t.render();
    assertEquals(expecting, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroup

    String result = t.render();
    assertEquals(expecting, result);
  }

  @Test public void testIndentedIFWithEndifNextLine() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("t", "x",
      "begin"+newline+
      "    <if(x)>foo\n" +      // use indent and keep newline
      "    <endif>"+newline+    // ignore indent on if-tags on line by themselves
      "end"+newline);
    ST t = group.getInstanceOf("t");
    t.add("x", "x");
    String expecting="begin"+newline+"    foo"+newline+"end";
    String result = t.render();
    assertEquals(expecting, 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.