Package com.github.mustachejava

Examples of com.github.mustachejava.MustacheFactory


        assertEquals(getContents(root, "bundles_post_labels.txt"), sw.toString());
    }

    @Test
    public void testPreNullLabels() throws MustacheException, IOException, ExecutionException, InterruptedException {
        MustacheFactory c = new DefaultMustacheFactory(root);
        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);
View Full Code Here


        assertEquals(getContents(root, "bundles_nulllabels.txt"), sw.toString());
    }

    @Test
    public void testPostNullLabels() throws MustacheException, IOException, ExecutionException, InterruptedException {
        MustacheFactory c = new DefaultMustacheFactory(root);
        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);
View Full Code Here

            ? new StaleSourceScanner(1024, Collections.singleton("**/*." + extension), Collections.<String>emptySet())
            : new SimpleSourceInclusionScanner(Collections.singleton("**/*." + extension), Collections.<String>emptySet());

    scanner.addSourceMapping(new SuffixMapping("." + extension, "." + extension));

    MustacheFactory mustacheFactory = new DefaultMustacheFactory();
    try {
      Set<File> files = scanner.getIncludedSources(sourceDirectory, outputDirectory);

      for (File file : files) {
        try {
          mustacheFactory.compile(new FileReader(file), file.getAbsolutePath());
        } catch (MustacheException e) {
          throw new MojoFailureException(e.getMessage(), e);
        }
      }

View Full Code Here

    System.out.println(sw);
  }

  @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

    assertNotNull(node);
  }

  @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

        if (!new File(rootDir, filename).exists()) {
          System.out.println("template not found, skipping: " + filename);
          return;
        }

        MustacheFactory mc = new DefaultMustacheFactory(rootDir);
        Mustache mustache = mc.compile(filename);

        String base = filename.substring(0, filename.lastIndexOf("."));
        File file = new File(mocks, base + ".json");
        Map parameters = new HashMap<Object, Object>(req.getParameterMap()) {
          @Override
View Full Code Here

    } catch (IllegalArgumentException e) {
      Args.usage(Main.class);
      System.exit(1);
    }

    MustacheFactory mb = new DefaultMustacheFactory("templates/" + language) {
      @Override
      public void encode(String value, Writer writer) {
        try {
          writer.write(value);
        } catch (IOException e) {
          throw new MustacheException();
        }
      }
    };
    Mustache mustache = mb.compile(template + ".txt");

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    XPathFactory xpf = XPathFactory.newInstance();
    final DocumentBuilder db = dbf.newDocumentBuilder();
    final XPathExpression replyX = xpf.newXPath().compile("//a");
View Full Code Here

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        Writer writer = new OutputStreamWriter(outputStream);

        String content = Resources.toString(resource, Charsets.UTF_8);

        MustacheFactory factory = new DefaultMustacheFactory();
        factory.compile(new StringReader(content), resource.toString())
            .execute(writer, scopes);

        writer.close();
        return outputStream.toString();
    }
View Full Code Here

        try {
            final ClassLoader loader = FirstClassCompiler.class.getClassLoader();
            thread.setContextClassLoader(loader);

            final MustacheFactory factory = new DefaultMustacheFactory();
            final Mustache mustache = factory.compile("templates/template.mustache");

            try {
                final Filer filer = processingEnv.getFiler();
                final JavaFileObject file = filer.createSourceFile(type.getName().getQualified());
View Full Code Here

        try {
            final ClassLoader loader = FunctorCompiler.class.getClassLoader();
            thread.setContextClassLoader(loader);

            final MustacheFactory factory = new DefaultMustacheFactory();
            final Mustache mustache = factory.compile("templates/template.mustache");

            try {
                final Filer filer = processingEnv.getFiler();
                final JavaFileObject file = filer.createSourceFile(type.getName().getQualified());
View Full Code Here

TOP

Related Classes of com.github.mustachejava.MustacheFactory

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.