Package com.github.mustachejava

Examples of com.github.mustachejava.Mustache.execute()


        Mustache m = c.compile("bundles.html");
        StringWriter sw = new StringWriter();
        Map<String, Object> scope = new HashMap<String, Object>();
        scope.put("trans", BundleFunctions.newPostTranslate(BUNDLE, Locale.US));
        scope.put("replaceMe", "replaced");
        m.execute(sw, scope);
        assertEquals(getContents(root, "bundles_post_labels.txt"), sw.toString());
    }

    @Test
    public void testPreNullLabels() throws MustacheException, IOException, ExecutionException, InterruptedException {
View Full Code Here


        Mustache m = c.compile("bundles.html");
        StringWriter sw = new StringWriter();
        Map<String, Object> scope = new HashMap<String, Object>();
        scope.put("trans", BundleFunctions.newPreTranslateNullableLabel(BUNDLE, Locale.US));
        scope.put("replaceMe", "replaced");
        m.execute(sw, scope);
        assertEquals(getContents(root, "bundles_nulllabels.txt"), sw.toString());
    }

    @Test
    public void testPostNullLabels() throws MustacheException, IOException, ExecutionException, InterruptedException {
View Full Code Here

        Mustache m = c.compile("bundles.html");
        StringWriter sw = new StringWriter();
        Map<String, Object> scope = new HashMap<String, Object>();
        scope.put("trans", BundleFunctions.newPostTranslateNullableLabel(BUNDLE, Locale.US));
        // Intentionally leave off the replacement value
        m.execute(sw, scope);
        assertEquals(getContents(root, "bundles_nulllabels.txt"), sw.toString());
    }

    protected String getContents(File root, String file) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(root, file)),"UTF-8"));
View Full Code Here

        while (true) {
          semaphore.acquire();
          es.submit(new Runnable() {
            @Override
            public void run() {
              parse.execute(new NullWriter(), new Object[] { parent });
              runs.incrementAndGet();
              semaphore.release();
            }
          });
          if (System.currentTimeMillis() - start > TIME * 1000) {
View Full Code Here

    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);
  }

  @Test
  public void testCollectPoints() throws Exception {
View Full Code Here

          JsonParser parser = JSON_FACTORY.createJsonParser(br);
          JsonNode json = parser.readValueAsTree();
          br.close();
          scs.add(0, toObject(json));
        }
        mustache.execute(res.getWriter(), scs.toArray());
      }

      private String simpleEscape(String string) {
        return string.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
      }
View Full Code Here

            }

            // Execute Mustache
            Map<String, Object> variableMap = ExchangeHelper.createVariableMap(exchange);
            StringWriter writer = new StringWriter();
            newMustache.execute(writer, variableMap);
            writer.flush();

            // Fill out message
            Message out = exchange.getOut();
            out.setBody(writer.toString());
View Full Code Here

    Mustache mustache = set.compileMustache(reader, resourceName);
    BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
    Object context = set.getContext();

    mustache.execute(writer, context).flush();
  }

}
View Full Code Here

    Mustache mustache = set.compileMustache(reader, resourceName);
    BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
    Object context = set.getContext();

    mustache.execute(writer, context).flush();
  }

}
View Full Code Here

    Map<String, Object> ctx = new HashMap<String, Object>();
    ctx.put("commands", commands);
    File base = new File(dest, pkg.replace(".", "/"));
    base.mkdirs();
    mustache.execute(new FileWriter(new File(base, className + "." + language)), ctx).close();
  }
}
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.