Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.STGroupFile


        "<stat(name)>" +newline+
        ">>"+newline+
        "stat(name,x=true,y=false) ::= \"<name>; <x> <y>\""+newline
        ;
    writeFile(tmpdir, "group.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/group.stg");
    ST b = group.getInstanceOf("method");
    b.add("name", "foo");
    String expecting = "foo; true false";
    String result = b.render();
    assertEquals(expecting, result);
  }
View Full Code Here


  @Test public void testDefaultArgument2() throws Exception {
    String templates =
        "stat(name,value=\"99\") ::= \"x=<value>; // <name>\""+newline
        ;
    writeFile(tmpdir, "group.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/group.stg");
    ST b = group.getInstanceOf("stat");
    b.add("name", "foo");
    String expecting = "x=99; // foo";
    String result = b.render();
    assertEquals(expecting, result);
  }
View Full Code Here

      "x: <x>\n" +
      "y: <y>\n" +
      ">>"+newline
      ;
    writeFile(tmpdir, "group.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/group.stg");
    ST b = group.getInstanceOf("t");
    b.add("x", "a");
    String expecting =
      "x: a" +newline+
      "y: afoo";
    String result = b.render();
View Full Code Here

  @Test public void testDefaultArgumentAsSimpleTemplate() throws Exception {
    String templates =
        "stat(name,value={99}) ::= \"x=<value>; // <name>\""+newline
        ;
    writeFile(tmpdir, "group.stg", templates);
    STGroup group = new STGroupFile(tmpdir+"/group.stg");
    ST b = group.getInstanceOf("stat");
    b.add("name", "foo");
    String expecting = "x=99; // foo";
    String result = b.render();
    assertEquals(expecting, result);
  }
View Full Code Here

                "<fields:{f | <stat(f)>}>" +newline+
                ">>"+newline+
                "stat(f,value={<f.name>}) ::= \"x=<value>; // <f.name>\""+newline
                ;
        writeFile(tmpdir, "group.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/group.stg");
        ST m = group.getInstanceOf("method");
        m.add("fields", new Field());
        String expecting = "x=parrt; // parrt";
        String result = m.render();
        assertEquals(expecting, result);
    }
View Full Code Here

                "<fields:{f | <stat()>}>" +newline+
                ">>"+newline+
                "stat(value={<f.name>}) ::= \"x=<value>; // <f.name>\""+newline
                ;
        writeFile(tmpdir, "group.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/group.stg");
        ST m = group.getInstanceOf("method");
        m.add("fields", new Field());
        String expecting = "x=parrt; // parrt";
        String result = m.render();
        assertEquals(expecting, result);
    }
View Full Code Here

                "<fields:{f | <f:stat()>}>" +newline+
                ">>"+newline+
                "stat(f,value={<f.name>}) ::= \"x=<value>; // <f.name>\""+newline
                ;
        writeFile(tmpdir, "group.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/group.stg");
        ST m = group.getInstanceOf("method");
        m.add("fields", new Field());
        String expecting = "x=parrt; // parrt";
        String result = m.render();
        assertEquals(expecting, result);
    }
View Full Code Here

                "<stat(name)>" +newline+
                ">>"+newline+
                "stat(name,value={<name>}) ::= \"x=<value>; // <name>\""+newline
                ;
        writeFile(tmpdir, "group.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/group.stg");
        ST b = group.getInstanceOf("method");
        b.add("name", "foo");
        b.add("size", "2");
        String expecting = "x=foo; // foo";
        String result = b.render();
        //System.err.println("result='"+result+"'");
View Full Code Here

                "<stat(name)>" +newline+
                ">>"+newline+
                "stat(name,value={ [<name>] }) ::= \"x=<value>; // <name>\""+newline
                ;
        writeFile(tmpdir, "group.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/group.stg");
        ST b = group.getInstanceOf("method");
        b.add("name", "foo");
        b.add("size", "2");
        String expecting = "x=[foo] ; // foo"; // won't see ' ' after '=' since it's an indent not simple string
        String result = b.render();
        //System.err.println("result='"+result+"'");
View Full Code Here

                "<stat(name,\"34\")>" +newline+
                ">>"+newline+
                "stat(name,value=\"99\") ::= \"x=<value>; // <name>\""+newline
                ;
        writeFile(tmpdir, "group.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/group.stg");
        ST b = group.getInstanceOf("method");
        b.add("name", "foo");
        String expecting = "x=34; // foo";
        String result = b.render();
        assertEquals(expecting, result);
    }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.STGroupFile

Copyright © 2018 www.massapicom. 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.