Package groovy.text

Examples of groovy.text.Template.make()


        Template template = cachedFragments.get(templateText);
        if (template==null) {
            template = engine.createTemplate(new StringReader(templateText));
            cachedFragments.put(templateText, template);
        }
        template.make(model).writeTo(out);
        return this;
    }

    /**
     * Imports a template and renders it using the specified model, allowing fine grained composition
View Full Code Here


    if (template == null) {
      return null;
    }
    try {
      final Template templateObject = templateEngine.createTemplate(template);
      final Writable writable = templateObject.make(variables);
      final StringWriter writer = new StringWriter();
      writable.writeTo(writer);
      writer.flush();
      if (log.isDebugEnabled() == true) {
        log.debug(writer.toString());
View Full Code Here

    @Override
    public void renderDocument(final Map<String, Object> model, final String templateName, final Writer writer) throws RenderingException {
        try {
            Template template = findTemplate(templateName);
            Writable writable = template.make(wrap(model));
            writable.writeTo(writer);
        } catch (Exception e) {
            throw new RenderingException(e);
        }
    }
View Full Code Here

    String contentType = template.getContentType();
    contentType = contentType == null ? context.get(MimeTypes.class).getContentType(template.getName()) : contentType;
    try {

      Template compiledTemplate = engine.createTemplateByPath(template.getName());
      Writable boundTemplate = compiledTemplate.make(template.getModel());
      context.getResponse().send(contentType, boundTemplate.toString());
    } catch (IOException e) {
      context.error(e);
    }
  }
View Full Code Here

    try {
      // auto import some utils
      String header = "<%import static org.groovymud.utils.WordUtils.*;\nimport static org.groovymud.utils.NumberToWordConverter.*%>";
      Template template = engine.createTemplate(header + text);

      stream.writeln(colorizeText(template.make(binding).toString(), BOLD));
    } catch (CompilationFailedException e) {
      logger.error(e, e);
    } catch (ClassNotFoundException e) {
      logger.error(e, e);
    } catch (IOException e) {
View Full Code Here

    try {
      //auto import some utils
      String header = "<%import static org.groovymud.utils.WordUtils.*;\nimport static org.groovymud.utils.NumberToWordConverter.*%>";
      Template template = engine.createTemplate(header + text);

      stream.writeln(colorizeText(template.make(binding).toString(), BOLD));
    } catch (CompilationFailedException e) {
      logger.error(e, e);
    } catch (ClassNotFoundException e) {
      logger.error(e, e);
    } catch (IOException e) {
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.