Package freemarker.template

Examples of freemarker.template.Template.process()


            if (null == currentUser) {
                topBarModel.put(Common.LOGIN_URL, userService.createLoginURL(Common.ADMIN_INDEX_URI));
                topBarModel.put("loginLabel", langPropsService.get("loginLabel"));

                topBarTemplate.process(topBarModel, stringWriter);

                return stringWriter.toString();
            }

            topBarModel.put(Common.IS_LOGGED_IN, true);
View Full Code Here


            topBarModel.put("logoutLabel", langPropsService.get("logoutLabel"));

            final String userName = currentUser.getString(User.USER_NAME);
            topBarModel.put(User.USER_NAME, userName);

            topBarTemplate.process(topBarModel, stringWriter);

            return stringWriter.toString();
        } catch (final JSONException e) {
            LOGGER.log(Level.SEVERE, "Gens top bar HTML failed", e);
            throw new ServiceException(e);
View Full Code Here

                final PrintWriter writer = response.getWriter();

                final StringWriter stringWriter = new StringWriter();
                template.setOutputEncoding("UTF-8");
                template.process(getDataModel(), stringWriter);

                final String pageContent = stringWriter.toString();
                context.getRequest().setAttribute(CACHED_CONTENT, pageContent);

                writer.write(pageContent);
View Full Code Here

  private String getTargetFilename(final IGeneratorModelProvider modelProvider, final String templateFilepath) throws Exception {
    final Map fileModel = getFilePathDataModel(modelProvider);
    final StringWriter out = new StringWriter();
    final Template template = new Template("filePath",new StringReader(templateFilepath),newFreeMarkerConfiguration());
    try {
      template.process(fileModel, out);
      return out.toString();
    }catch(final Exception e) {
      throw new IllegalStateException("cannot generate filePath from templateFilepath:"+templateFilepath+" cause:"+e,e);
    }
  }
View Full Code Here

   
    PrintWriter writer = null;
        try {
      Template template = config.getTemplate(view);
      writer = response.getWriter();
      template.process(root, writer);    // Merge the data-model and the template
    } catch (Exception e) {
      throw new RenderException(e);
    }
    finally {
      if (writer != null)
View Full Code Here

            Template template = new Template( name,
                                              new InputStreamReader( ServiceImplementation.class.getResourceAsStream( "/repoconfig/" + name + ".xml" ) ),
                                              configuration );
            StringWriter stringwriter = new StringWriter();
            template.process( data,
                              stringwriter );
            return StringEscapeUtils.escapeXml( stringwriter.toString() );
        } catch ( Exception e ) {
            return "";
        }
View Full Code Here

      cfg.setObjectWrapper(new DefaultObjectWrapper());
      cfg.setTemplateUpdateDelay(0);
      Template temp = new Template(name, new InputStreamReader(src), cfg);
      final ByteArrayOutputStream bout = new ByteArrayOutputStream();
      Writer out = new OutputStreamWriter(bout);
      temp.process(renderContext, out);
      out.flush();
      merged = new DataHandler(new DataSource() {
        public InputStream getInputStream() throws IOException {
          return new ByteArrayInputStream(bout.toByteArray());
        }
View Full Code Here

   {
      String id = loader.register(resource);
      try
      {
         Template templateFile = getFreemarkerConfig().getTemplate(id);
         templateFile.process(dataModel, writer);
         writer.flush();
      }
      catch (TemplateException e)
      {
         throw new RuntimeException(e);
View Full Code Here

        {
          Template temp = cfg.getTemplate(templates.get(i));

          Writer out = new FileWriter(Espeon.outputPath + "/" + entry.getKey() + "-" + templates.get(i));

          temp.process(entry.getValue(), out);

          out.flush();
        }
        catch(Exception e)
        {
View Full Code Here

        Map<String, Object> ctx = FastMap.newInstance();
        ctx.put("doc", nodeModel);
        ctx.put("entityName", entityName);
        StringWriter outWriter = new StringWriter();
        Template template = getDocTemplate(templatePath);
        template.process(ctx, outWriter);
        outWriter.close();
        result = outWriter.toString();
        return result;
    }
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.