Package com.github.mustachejava

Examples of com.github.mustachejava.DefaultMustacheFactory


  @Override
  protected void doInit(ClassLoader loader) {
    ClassLoader previous = Thread.currentThread().getContextClassLoader();
    try {
      Thread.currentThread().setContextClassLoader(loader);
      DefaultMustacheFactory factory = new DefaultMustacheFactory(resourceRoot) {
        @Override
        public MustacheVisitor createMustacheVisitor() {
          return new DefaultMustacheVisitor(this) {
            @Override
            public void pragma(TemplateContext templateContext, String pragma, String args) {
              if ("param".equals(pragma)) {
                // Do nothing
              } else {
                super.pragma(templateContext, pragma, args);
              }
            }
          };
        }
      };
      mustache = factory.compile(mustacheName);
    }
    finally {
      Thread.currentThread().setContextClassLoader(previous);
    }
  }
View Full Code Here


     *            the writer where the plan is written to
     * @throws IOException
     *             if an error occurred during write
     */
    public void generate(Writer writer) throws IOException {
        MustacheFactory mf = new DefaultMustacheFactory();
        Mustache mustache = mf.compile("data/t2flow/workflow.mustache");
        mustache.execute(writer, workflow).flush();
    }
View Full Code Here

        try {
            final ClassLoader loader = HammockCompiler.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

  static MustacheFactory resourcesMf() {
    try {
      File tempDir = Files.createTempDir();
      return newMustacheFactoryAt(tempDir);
    } catch (IOException e) {
      return new DefaultMustacheFactory();
    }
  }
View Full Code Here

  private static MustacheFactory newMustacheFactoryAt(File dir) throws IOException {
    copyMustache("boleto.mustache", dir);
    copyMustache("boleto-inline-css.mustache", dir);
    copyMustache("boleto-page.mustache", dir);

    return new DefaultMustacheFactory(dir);
  }
View Full Code Here

    return mustacheFactory.compile(name + ".mustache");
  }

  MustacheFactory newMustacheFactory(PagesBaseDir pagesBaseDir) {
    String resourceRoot = pagesBaseDir.getBaseDir();
    return new DefaultMustacheFactory(resourceRoot);
  }
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

        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

    return uri;
  }

  private DefaultMustacheFactory getMustacheFactory() {
    if (mustacheFileRoot == null) {
      return new DefaultMustacheFactory();
    } else {
      return new DefaultMustacheFactory(new File(mustacheFileRoot));
    }
  }
View Full Code Here

TOP

Related Classes of com.github.mustachejava.DefaultMustacheFactory

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.