Package org.apache.velocity

Examples of org.apache.velocity.Template.merge()


          }
         
          StringWriter writer = new StringWriter();

          if (template != null)
            template.merge(context, writer);
         
          writer.flush();
          writer.close();

          FileUtils.writeStringToFile(new File(destFile, "oorexxdocdata/"+DocGenerator.getPathOfFile(container.getFile(), srcFileScopes)+"/routine-"+routine.getName()+".html"), writer.getBuffer().toString());
View Full Code Here


            file.getParentFile().mkdirs();
            getLog().info("Generating source file " + file.getAbsolutePath() + "...");
            VelocityEngine engine = createVelocityEngine();
            final Template template = engine.getTemplate(templateName);
            final FileWriter fw = new FileWriter(file);
            template.merge(context, fw);
            fw.close();
        }
        catch( Exception e )
        {
            throw new MojoExecutionException("Unable to generate source file for class " + className + ".", e);
View Full Code Here

            }
          
            StringWriter writer = new StringWriter();
           
            Template template = Velocity.getTemplate(report.getFile());          
            template.merge(context, writer);         
           
            ReportEngineOutput output = new ReportEngineOutput();
            output.setContent(writer.toString().getBytes());
           
            if (input.getExportType() == ExportType.HTML)
View Full Code Here

        Template template = Velocity.getTemplate("target/test-classes/hello.vm");

        StringWriter sw = new StringWriter();

        template.merge(context, sw);
    }
}
View Full Code Here

    // Load template from templatePath
    String templateName = ((String) args[0]).substring(slashIndex);
    Template template = Velocity.getTemplate(templateName);
    // Fill out template and write to file
    StringWriter sw = new StringWriter();
    template.merge(context, sw);
    FileUtils.writeStringToFile(configFile, sw.toString());
    return configFile;
  }

}
View Full Code Here

        }

        VelocityWriter writer = new VelocityWriter(outputs);
        ctx.put("out", writer);
        try {
            tmpl.merge(ctx, writer);
            writer.close();
        } catch (Exception e) {
            Message msg = new Message("VELOCITY_ENGINE_WRITE_ERRORS", LOG);
            throw new ToolException(msg, e);
        }
View Full Code Here

            Writer writer = new OutputStreamWriter( new FileOutputStream( f ), templateEncoding );

            Template velocityTemplate = engine.getTemplate( templateDirectory + "/" + template, templateEncoding );

            velocityTemplate.merge( context, writer );

            writer.flush();

            writer.close();
View Full Code Here

      template = this.velocityEngine.getTemplate(templateName);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    StringWriter writer = new StringWriter();
    template.merge(context, writer);
    return writer.toString();
  }

  OutputFile compileInterface(Protocol protocol) {
    protocol = addStringType(protocol);           // annotate protocol as needed
View Full Code Here

             *  of the template and the data to produce the output stream.
             */
            FileWriter writer = new FileWriter( outputFile );
            if ( template != null )
            {
                template.merge( context, writer );
            }
            writer.close();
        }
        catch ( Exception e )
        {
View Full Code Here

    setParameters(relay);
    Template template = engine.getTemplate(relay.getRealPath(path));
    VelocityContext context = new VelocityContext(relay.getDataMap());
    response.setContentType(type);
    response.setCharacterEncoding(encoding);
    template.merge(context, response.getWriter());
  }
}
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.