Package com.github.mustachejava

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


      Mustache mustache = mustaches.compile(templateClass);

      StringWriter writer = new StringWriter();
      Map<?, ?> scope = toMustacheScope(context);

      Writer execute = mustache.execute(writer, scope);
      execute.flush();

      return writer.toString();

    } catch (IOException e) {
View Full Code Here


    @Override
    public void execute(final Reader input, final Writer output, final String name, final Object parameters) {
        try {
            final Mustache template = MUSTACHE.compile(input, name);
            template.execute(output, parameters);
        }
        catch (MustacheException e) {
            final Throwable cause = Throwables.getRootCause(e);
            Throwables.propagateIfInstanceOf(cause, MissingParameterException.class);
            throw e;
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

        try {
            final Mustache template = factories.get(view.getClass())
                                               .compile(view.getTemplateName());
            final Charset charset = view.getCharset().or(Charsets.UTF_8);
            try (OutputStreamWriter writer = new OutputStreamWriter(output, charset)) {
                template.execute(writer, view);
            }
        } catch (ExecutionException | UncheckedExecutionException | MustacheException ignored) {
            throw new FileNotFoundException("Template " + view.getTemplateName() + " not found.");
        }
    }
View Full Code Here

      InputStream stream = getClass().getResourceAsStream(templateName);
      if (stream == null) {
        throw new MustacheException("Template not found: " + templateName);
      }
      Mustache mustache = mf.compile(new InputStreamReader(stream), templateName);
      mustache.execute(response.getWriter(), parameters);

      response.setStatus(status);
      response.setContentType(contentType);
    } catch (MustacheException e) {
      LOG.error("Template exception.", e);
View Full Code Here

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

                try (Writer writer = file.openWriter()) {
                    mustache.execute(writer, type).flush();
                }
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
        } finally {
View Full Code Here

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

                try (Writer writer = file.openWriter()) {
                    mustache.execute(writer, type).flush();
                }
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
        } finally {
View Full Code Here

      Mustache mustache = mustaches.compile(templateClass);

      StringWriter writer = new StringWriter();
      Map<?, ?> scope = toMustacheScope(context);

      Writer execute = mustache.execute(writer, scope);
      execute.flush();

      return writer.toString();

    } catch (IOException e) {
View Full Code Here

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

        final StringWriter stringWriter = new StringWriter();
        mustache.execute(stringWriter, this.scopes);

        return stringWriter.toString();
    }

    private Map<String, Object> getCompiledMapFromMappers(final Map<String, String> data) {
View Full Code Here

            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")) {
                    url = this.scopes.get("BASE_URI") + url;
                }
                try {
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.