Examples of defineTemplate()


Examples of org.stringtemplate.v4.STGroup.defineTemplate()

        assertEquals(expected, result);
    }

  @Test public void testParallelMapThenMap() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("bold", "x", "[<x>]");
    group.defineTemplate("test", "names,phones",
               "hi <names,phones:{n,p | <n>:<p>;}:bold()>");
    ST st = group.getInstanceOf("test");
    st.add("names", "Ter");
    st.add("names", "Tom");
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

    }

  @Test public void testParallelMapThenMap() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("bold", "x", "[<x>]");
    group.defineTemplate("test", "names,phones",
               "hi <names,phones:{n,p | <n>:<p>;}:bold()>");
    ST st = group.getInstanceOf("test");
    st.add("names", "Ter");
    st.add("names", "Tom");
    st.add("names", "Sumana");
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

    assertEquals(expected, result);
  }

  @Test public void testMapThenParallelMap() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("bold", "x", "[<x>]");
    group.defineTemplate("test", "names,phones",
               "hi <[names:bold()],phones:{n,p | <n>:<p>;}>");
    ST st = group.getInstanceOf("test");
    st.add("names", "Ter");
    st.add("names", "Tom");
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

  }

  @Test public void testMapThenParallelMap() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("bold", "x", "[<x>]");
    group.defineTemplate("test", "names,phones",
               "hi <[names:bold()],phones:{n,p | <n>:<p>;}>");
    ST st = group.getInstanceOf("test");
    st.add("names", "Ter");
    st.add("names", "Tom");
    st.add("names", "Sumana");
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

    assertEquals(expected, result);
  }

  @Test public void testMapIndexes() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("inc", "x,i", "<i>:<x>");
    group.defineTemplate("test", "name", "<name:{n|<inc(n,i)>}; separator=\", \">");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    st.add("name", "Tom");
    st.add("name", null); // don't count this one
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

  }

  @Test public void testMapIndexes() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("inc", "x,i", "<i>:<x>");
    group.defineTemplate("test", "name", "<name:{n|<inc(n,i)>}; separator=\", \">");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    st.add("name", "Tom");
    st.add("name", null); // don't count this one
    st.add("name", "Sumana");
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

    assertEquals(expected, result);
  }

  @Test public void testMapIndexes2() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("test", "name", "<name:{n | <i>:<n>}; separator=\", \">");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    st.add("name", "Tom");
    st.add("name", null); // don't count this one. still can't apply subtemplate to null value
    st.add("name", "Sumana");
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

    assertEquals(expected, result);
  }

  @Test public void testMapSingleValue() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("a", "x", "[<x>]");
    group.defineTemplate("test", "name", "hi <name:a()>!");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    String expected = "hi [Ter]!";
    String result = st.render();
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

  }

  @Test public void testMapSingleValue() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("a", "x", "[<x>]");
    group.defineTemplate("test", "name", "hi <name:a()>!");
    ST st = group.getInstanceOf("test");
    st.add("name", "Ter");
    String expected = "hi [Ter]!";
    String result = st.render();
    assertEquals(expected, result);
View Full Code Here

Examples of org.stringtemplate.v4.STGroup.defineTemplate()

    assertEquals(expected, result);
  }

  @Test public void testMapNullValue() throws Exception {
    STGroup group = new STGroup();
    group.defineTemplate("a", "x", "[<x>]");
    group.defineTemplate("test", "name", "hi <name:a()>!");
    ST st = group.getInstanceOf("test");
    String expected = "hi !";
    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.