Package com.github.mustachejava.util

Examples of com.github.mustachejava.util.Node


  @Override
  public Node invert(Node node, String text, AtomicInteger position) {
    int start = position.get();
    List<Node> nodes = new ArrayList<Node>();
    Node invert;
    while ((invert = mustache.invert(new Node(), text, position)) != null) {
      nodes.add(invert);
    }
    node.put(name, list(nodes));
    if (appended == null) {
      return node;
View Full Code Here


   * @param text
   * @return
   */
  @Override
  public Node invert(String text) {
    return invert(new Node(), text, new AtomicInteger(0));
  }
View Full Code Here

  public Node invert(Node node, String text, AtomicInteger position) {
    int start = position.get();
    Code[] codes = getCodes();
    if (codes != null) {
      for (Code code : codes) {
        Node invert = code.invert(node, text, position);
        if (invert == null) {
          position.set(start);
          return null;
        }
      }
View Full Code Here

  public void testParser() throws IOException {
    DefaultMustacheFactory dmf = new DefaultMustacheFactory();
    Mustache compile = dmf.compile("fdbcli.mustache");
    Path file = getPath("src/test/resources/fdbcli.txt");
    String txt = new String(Files.readAllBytes(file), "UTF-8");
    Node invert = compile.invert(txt);
    System.out.println(invert);
  }
View Full Code Here

  @Test
  public void testSimple() throws IOException {
    DefaultMustacheFactory dmf = new DefaultMustacheFactory();
    Mustache test = dmf.compile(new StringReader("test {{value}} test"), "test");
    Node invert = test.invert("test value test");
    Node node = new Node();
    node.put("value", value("value"));
    assertEquals(node, invert);
  }
View Full Code Here

  @Test
  public void testIterable() throws IOException {
    DefaultMustacheFactory dmf = new DefaultMustacheFactory();
    Mustache test = dmf.compile(new StringReader("{{#values}}\ntest: {{value}}\n{{/values}}"), "test");
    Node invert = test.invert("test: sam\ntest: fred\n");
    Node node = new Node();
    Node sam = new Node();
    sam.put("value", value("sam"));
    Node fred = new Node();
    fred.put("value", value("fred"));
    node.put("values", list(asList(sam, fred)));
    assertEquals(node, invert);
    StringWriter sw = new StringWriter();
    test.execute(sw, invert).close();
    System.out.println(sw);
View Full Code Here

  @Test
  public void testCollectPoints() throws Exception {
    MustacheFactory dmf = new DefaultMustacheFactory();
    Mustache compile = dmf.compile(new StringReader("{{#page}}This is a {{test}}{{/page}}"),
            UUID.randomUUID().toString());
    Node node = compile.invert("This is a good day");
    assertNotNull(node);
  }
View Full Code Here

  @Test
  public void testNoNode() throws Exception {
    MustacheFactory dmf = new DefaultMustacheFactory();
    Mustache compile = dmf.compile(new StringReader("Using cluster file [^\\n]+\nHello World"),
        UUID.randomUUID().toString());
    Node node = compile.invert("Using cluster file `/etc/foundationdb/fdb.cluster'.\nHello World");
    assertNotNull(node);
  }
View Full Code Here

  public void testToJson() throws IOException {
    DefaultMustacheFactory dmf = new DefaultMustacheFactory();
    Mustache compile = dmf.compile("fdbcli.mustache");
    Path file = getPath("src/test/resources/fdbcli.txt");
    String txt = new String(Files.readAllBytes(file), "UTF-8");
    Node invert = compile.invert(txt);

    MappingJsonFactory jf = new MappingJsonFactory();
    StringWriter out = new StringWriter();
    JsonGenerator jg = jf.createJsonGenerator(out);
    writeNode(jg, invert);
View Full Code Here

  public void testToJson2() throws IOException {
    DefaultMustacheFactory dmf = new DefaultMustacheFactory();
    Mustache compile = dmf.compile("fdbcli2.mustache");
    Path file = getPath("src/test/resources/fdbcli2.txt");
    String txt = new String(Files.readAllBytes(file), "UTF-8");
    Node invert = compile.invert(txt);

    MappingJsonFactory jf = new MappingJsonFactory();
    StringWriter out = new StringWriter();
    JsonGenerator jg = jf.createJsonGenerator(out);
    writeNode(jg, invert);
View Full Code Here

TOP

Related Classes of com.github.mustachejava.util.Node

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.