Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.ST.render()


    ST st = group.getInstanceOf("test");
    st.add("name", null); // null is added to list, but ignored in iteration
    st.add("name", "Tom");
    st.add("name", "Sumana");
    String expected = "hi Tom, Sumana!";
    String result = st.render();
    assertEquals(expected, result);
  }

  @Test public void testTemplateAppliedToNullIsEmpty() throws Exception {
    STGroup group = new STGroup();
View Full Code Here


    group.defineTemplate("test", "name", "<name:t()>");
    group.defineTemplate("t", "x", "<x>");
    ST st = group.getInstanceOf("test");
    st.add("name", null);
    String expected = "";
    String result = st.render();
    assertEquals(expected, result);
  }

  @Test public void testTemplateAppliedToMissingValueIsEmpty() throws Exception {
    STGroup group = new STGroup();
View Full Code Here

    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "<name:t()>");
    group.defineTemplate("t", "x", "<x>");
    ST st = group.getInstanceOf("test");
    String expected = "";
    String result = st.render();
    assertEquals(expected, result);
  }

    @Test public void testSeparatorWithNull2ndValue() throws Exception {
        STGroup group = new STGroup();
View Full Code Here

        ST st = group.getInstanceOf("test");
        st.add("name", "Ter");
        st.add("name", null);
        st.add("name", "Sumana");
        String expected = "hi Ter, Sumana!";
        String result = st.render();
        assertEquals(expected, result);
    }

    @Test public void testSeparatorWithNullLastValue() throws Exception {
        STGroup group = new STGroup();
View Full Code Here

        ST st = group.getInstanceOf("test");
        st.add("name", "Ter");
        st.add("name", "Tom");
        st.add("name", null);
        String expected = "hi Ter, Tom!";
        String result = st.render();
        assertEquals(expected, result);
    }

  @Test public void testSeparatorWithTwoNullValuesInRow() throws Exception {
    STGroup group = new STGroup();
View Full Code Here

    st.add("name", "Tom");
    st.add("name", null);
    st.add("name", null);
    st.add("name", "Sri");
    String expected = "hi Ter, Tom, Sri!";
    String result = st.render();
    assertEquals(expected, result);
  }

  @Test public void testTwoNullValues() throws Exception {
    STGroup group = new STGroup();
View Full Code Here

    group.defineTemplate("test", "name", "hi <name; null=\"x\">!");
    ST st = group.getInstanceOf("test");
    st.add("name", null);
    st.add("name", null);
    String expected = "hi xx!";
    String result = st.render();
    assertEquals(expected, result);
  }

  @Test public void testNullListItemNotCountedForIteratorIndex() throws Exception {
    STGroup group = new STGroup();
View Full Code Here

    st.add("name", "Ter");
    st.add("name", null);
    st.add("name", null);
    st.add("name", "Jesse");
    String expected = "1:Ter2:Jesse";
    String result = st.render();
    assertEquals(expected, result);
  }

    @Test public void testSizeZeroButNonNullListGetsNoOutput() throws Exception {
        STGroup group = new STGroup();
View Full Code Here

            "<users>\n" +
            "end\n");
        ST t = group.getInstanceOf("test");
        t.add("users", null);
        String expecting="begin"+newline+"end";
        String result = t.render();
        assertEquals(expecting, result);
    }

    @Test public void testNullListGetsNoOutput() throws Exception {
        STGroup group = new STGroup();
View Full Code Here

            "begin\n" +
            "<users:{u | name: <u>}; separator=\", \">\n" +
            "end\n");
        ST t = group.getInstanceOf("test");
        String expecting="begin"+newline+"end";
        String result = t.render();
        assertEquals(expecting, result);
    }

    @Test public void testEmptyListGetsNoOutput() throws Exception {
        STGroup group = new STGroup();
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.