Package com.github.mustachejava

Examples of com.github.mustachejava.DefaultMustacheFactory.compile()


        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

        this.scopes = scopes;
        this.scopes.put("static", new TemplateFunctions());

        final MustacheFactory mf = new DefaultMustacheFactory();
        final Mustache mustache = mf.compile(new StringReader(template.getText()), template.getName());

        final Map<String, Object> mappers = getCompiledMapFromMappers(template.getMappersAsMap());
        this.scopes.putAll(mappers);

        final StringWriter stringWriter = new StringWriter();
View Full Code Here

        final MustacheFactory mf = new DefaultMustacheFactory();

        if (data != null) {
            for (final Map.Entry<String, String> entry : data.entrySet()) {

                final Mustache mappersMustache = mf.compile(new StringReader(entry.getValue()), "");
                final StringWriter stringWriter = new StringWriter();

                mappersMustache.execute(stringWriter, this.scopes);
                String url = stringWriter.toString();
                if (!url.startsWith("http")) {
View Full Code Here

        String subject = jsonTemplate.getString("subject");
        String body = jsonTemplate.getString("body");
       
        MustacheFactory mf = new DefaultMustacheFactory();
       
        Mustache titleTemplate = mf.compile(new StringReader(subject), "subject");
        Mustache bodyTemplate = mf.compile(new StringReader(body), "body");
       
        // Subject
        {
          StringWriter sw = new StringWriter();
View Full Code Here

        String body = jsonTemplate.getString("body");
       
        MustacheFactory mf = new DefaultMustacheFactory();
       
        Mustache titleTemplate = mf.compile(new StringReader(subject), "subject");
        Mustache bodyTemplate = mf.compile(new StringReader(body), "body");
       
        // Subject
        {
          StringWriter sw = new StringWriter();
          titleTemplate.execute(sw, parameters);
View Full Code Here

  /** */
  public static void external_template_with_HelloMustache_object() throws IOException {
    MustacheFactory mf = new DefaultMustacheFactory();

    Mustache mustache = mf.compile("template.mustache");

    Writer stdout = new OutputStreamWriter(System.out);
    mustache.execute( stdout, new HelloMustache() );
    stdout.flush();
  }
View Full Code Here

    HashMap<String, Object> scopes = new HashMap<String, Object>();
    scopes.put("name", "Mustache");
    scopes.put("feature", new Feature("Perfect!"));

    Mustache mustache = mf.compile(new StringReader("{{name}}, {{feature.description}}!"), "example");

    Writer stdout = new OutputStreamWriter(System.out);
    mustache.execute(stdout, scopes);
    stdout.flush();
  }
View Full Code Here

        };
      }
    };

    // Does the name count ?
    factory.compile(new StringReader(mustacheTemplateModel.getModel().source), mustacheTemplateModel.getPath().getSimpleName());
  }

  @Override
  public void emit(EmitContext context, TemplateModel<MustacheContext> templateModel) throws TemplateException, IOException {
  }
View Full Code Here

              }
            }
          };
        }
      };
      mustache = factory.compile(mustacheName);
    }
    finally {
      Thread.currentThread().setContextClassLoader(previous);
    }
  }
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.