org.apache.velocity.app.Velocity.getTemplate()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(302)

本文整理了Java中org.apache.velocity.app.Velocity.getTemplate()方法的一些代码示例,展示了Velocity.getTemplate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Velocity.getTemplate()方法的具体详情如下:
包路径:org.apache.velocity.app.Velocity
类名称:Velocity
方法名:getTemplate

Velocity.getTemplate介绍

[英]Returns a Template from the Velocity resource management system.
[中]从Velocity资源管理系统返回Template

代码示例

代码示例来源:origin: looly/hutool

/**
 * 生成文件,使用默认引擎
 * 
 * @param templateFileName 模板文件名
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
  assertInit();
  toFile(Velocity.getTemplate(templateFileName), context, destPath);
}

代码示例来源:origin: looly/hutool

/**
 * 生成文件,使用默认引擎
 * 
 * @param templateFileName 模板文件名
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
  assertInit();
  toFile(Velocity.getTemplate(templateFileName), context, destPath);
}

代码示例来源:origin: looly/hutool

/**
 * 生成内容写入流<br>
 * 会自动关闭Writer
 * 
 * @param templateFileName 模板文件名
 * @param context 上下文
 * @param writer 流
 */
public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
  assertInit();
  final Template template = Velocity.getTemplate(templateFileName);
  merge(template, context, writer);
}

代码示例来源:origin: looly/hutool

/**
 * 生成内容写入流<br>
 * 会自动关闭Writer
 * 
 * @param templateFileName 模板文件名
 * @param context 上下文
 * @param writer 流
 */
public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
  assertInit();
  final Template template = Velocity.getTemplate(templateFileName);
  merge(template, context, writer);
}

代码示例来源:origin: shuzheng/zheng

/**
 * 根据模板生成文件
 * @param inputVmFilePath 模板路径
 * @param outputFilePath 输出文件路径
 * @param context
 * @throws Exception
 */
public static void generate(String inputVmFilePath, String outputFilePath, VelocityContext context) throws Exception {
  try {
    Properties properties = new Properties();
    properties.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, getPath(inputVmFilePath));
    Velocity.init(properties);
    //VelocityEngine engine = new VelocityEngine();
    Template template = Velocity.getTemplate(getFile(inputVmFilePath), "utf-8");
    File outputFile = new File(outputFilePath);
    FileWriterWithEncoding writer = new FileWriterWithEncoding(outputFile, "utf-8");
    template.merge(context, writer);
    writer.close();
  } catch (Exception ex) {
    throw ex;
  }
}

代码示例来源:origin: jfinal/jfinal

Template template = Velocity.getTemplate(view);

代码示例来源:origin: com.atlassian.selenium/atlassian-visual-comparison

public static String render(VelocityContext context, String templateName) throws Exception
 {
   Template template = Velocity.getTemplate(templateName);
   StringWriter sw = new StringWriter();
   template.merge(context, sw);
   return sw.toString();
 }
}

代码示例来源:origin: eclipse/winery

public String completeInvokerXsdTemplate() {
  LOGGER.debug("Retrieving service invoker XSD");
  VelocityContext context = new VelocityContext();
  Template invokerXsdTemplate = Velocity.getTemplate(TEMPLATE_PATH + "invoker.xsd");
  StringWriter xsdWriter = new StringWriter();
  invokerXsdTemplate.merge(context, xsdWriter);
  return xsdWriter.toString();
}

代码示例来源:origin: eclipse/winery

public String completeInvokerWsdlTemplate() {
  LOGGER.debug("Retrieving service invoker WSDL");
  VelocityContext context = new VelocityContext();
  Template invokerWsdlTemplate = Velocity.getTemplate(TEMPLATE_PATH + "invoker.wsdl");
  StringWriter wsdlWriter = new StringWriter();
  invokerWsdlTemplate.merge(context, wsdlWriter);
  return wsdlWriter.toString();
}

代码示例来源:origin: eclipse/winery

public String completeDeploymentDescriptorTemplate() {
  LOGGER.debug("Retrieving Apache ODE deployment descriptor");
  VelocityContext context = new VelocityContext();
  Template invokerXsdTemplate = Velocity.getTemplate(TEMPLATE_PATH + "deploy.xml");
  StringWriter xsdWriter = new StringWriter();
  invokerXsdTemplate.merge(context, xsdWriter);
  return xsdWriter.toString();
}

代码示例来源:origin: eclipse/winery

public String completePlanWsdlTemplate() {
  LOGGER.debug("Completing BPEL WSDL template");
  VelocityContext context = new VelocityContext();
  Template wsdlTemplate = Velocity.getTemplate(TEMPLATE_PATH + "management_plan_wsdl_template.xml");
  StringWriter wsdlWriter = new StringWriter();
  wsdlTemplate.merge(context, wsdlWriter);
  String bpelProcessWSDL = wsdlWriter.toString();
  LOGGER.debug("Completed BPEL WSDL template" + bpelProcessWSDL);
  return bpelProcessWSDL;
}

代码示例来源:origin: OpenNMS/opennms

private String generateSnmpGraphInternal(Collection<Report> reports, String graphTemplate) {
  Velocity.init();
  VelocityContext context = new VelocityContext();
  context.put("reportsList", reports.iterator());
  context.put("reportsBody", reports.iterator());
  Template template = Velocity.getTemplate(graphTemplate);
  StringWriter sw = new StringWriter();
  if (template != null) {
    template.merge(context, sw);
  }
  return sw.toString();
}

代码示例来源:origin: suninformation/ymate-platform-v2

@Override
public void render(OutputStream output) throws Exception {
  __doProcessPath();
  Velocity.getTemplate(__path).merge(__velocityContext, new BufferedWriter(new OutputStreamWriter(output)));
}

代码示例来源:origin: org.opennms.features/jmxconfiggenerator

private String generateSnmpGraphInternal(Collection<Report> reports, String graphTemplate) {
  Velocity.init();
  VelocityContext context = new VelocityContext();
  context.put("reportsList", reports.iterator());
  context.put("reportsBody", reports.iterator());
  Template template = Velocity.getTemplate(graphTemplate);
  StringWriter sw = new StringWriter();
  if (template != null) {
    template.merge(context, sw);
  }
  return sw.toString();
}

代码示例来源:origin: com.moomanow/moomanow-core

public String render(String templateName , Map<String,Object> values){
  Context context = convertToContext(values);
  Template template = Velocity.getTemplate(templateName);
  StringWriter sw = new StringWriter();
  template.merge( context, sw );
  return sw.toString();
}

代码示例来源:origin: baiczsy/evergreenframework

@Override
protected void execute() throws IOException {
  Template template = Velocity.getTemplate(vmpath);
  StringWriter writer = new StringWriter();
  template.merge(context, writer);
  getResponse().setContentType("text/html;charset=utf-8");
  getResponse().getWriter().println(writer.toString());
}

代码示例来源:origin: suninformation/ymate-platform-v2

@Override
protected void __doRenderView() throws Exception {
  __doProcessPath();
  Velocity.getTemplate(__path).merge(__velocityContext, WebContext.getResponse().getWriter());
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 生成文件,使用默认引擎
 * 
 * @param templateFileName 模板文件名
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
  assertInit();
  toFile(Velocity.getTemplate(templateFileName), context, destPath);
}

代码示例来源:origin: com.xiaoleilu/hutool

/**
 * 生成文件,使用默认引擎
 * 
 * @param templateFileName 模板文件名
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
  assertInit();
  toFile(Velocity.getTemplate(templateFileName), context, destPath);
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 生成内容写入流<br>
 * 会自动关闭Writer
 * 
 * @param templateFileName 模板文件名
 * @param context 上下文
 * @param writer 流
 */
public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
  assertInit();
  final Template template = Velocity.getTemplate(templateFileName);
  merge(template, context, writer);
}

相关文章