当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.VERSION_2_3_25属性代码示例

本文整理汇总了Java中freemarker.template.Configuration.VERSION_2_3_25属性的典型用法代码示例。如果您正苦于以下问题:Java Configuration.VERSION_2_3_25属性的具体用法?Java Configuration.VERSION_2_3_25怎么用?Java Configuration.VERSION_2_3_25使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在freemarker.template.Configuration的用法示例。


在下文中一共展示了Configuration.VERSION_2_3_25属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateResumeHTML

private String generateResumeHTML(String json, String theme) throws Exception {
    if (!isValidJSON(json)) {
        throw new InvalidJSONException();
    }

    Gson gson = new GsonBuilder().setPrettyPrinting().create();

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setDirectoryForTemplateLoading(new File("themes"));
    cfg.setDefaultEncoding("UTF-8");
    Template temp = cfg.getTemplate(theme + ".html");
    //System.out.println(json);
    Resume resume = gson.fromJson(json, Resume.class);
    resume.getRidOfArraysWithEmptyElements();
    resume.setConfig(config);
    StringWriter htmlStringWriter = new StringWriter();
    temp.process(resume, htmlStringWriter);
    String html = htmlStringWriter.toString();
    return html;
}
 
开发者ID:chenshuiluke,项目名称:jresume,代码行数:20,代码来源:ResumeGenerator.java

示例2: writeToFile

private static void writeToFile(IssuesReport report, Path toFile) {
  try {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setClassForTemplateLoading(HtmlReport.class, "");

    Map<String, Object> root = new HashMap<>();
    root.put("report", report);

    Template template = cfg.getTemplate("sonarlintreport.ftl");

    try (FileOutputStream fos = new FileOutputStream(toFile.toFile());
      Writer writer = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
      template.process(root, writer);
      writer.flush();
    }
  } catch (Exception e) {
    throw new IllegalStateException("Fail to generate HTML Issues Report to: " + toFile, e);
  }
}
 
开发者ID:SonarSource,项目名称:sonarlint-cli,代码行数:19,代码来源:HtmlReport.java

示例3: init

public void init() throws IOException {
    ClassTemplateLoader ctl = new ClassTemplateLoader(Application.class, "/freemarker");
    MultiTemplateLoader mtl = new MultiTemplateLoader(new TemplateLoader[] {ctl});

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setTemplateLoader(mtl);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);

    Pair<String, Template> clusterResourceQuota = new ImmutablePair<String, Template>("ClusterResourceQuota-ForUser", cfg.getTemplate("ClusterResourceQuota-ForUser.ftlh"));
    Pair<String, Template> bestEffortResourceLimits = new ImmutablePair<String, Template>("LimitRange-BestEffortResourceLimits", cfg.getTemplate("LimitRange-BestEffortResourceLimits.ftlh"));
    Pair<String, Template> burstableResourceLimits = new ImmutablePair<String, Template>("LimitRange-BurstableResourceLimits", cfg.getTemplate("LimitRange-BurstableResourceLimits.ftlh"));
    Pair<String, Template> maxImageCounts = new ImmutablePair<String, Template>("LimitRange-MaxImageCounts", cfg.getTemplate("LimitRange-MaxImageCounts.ftlh"));
    Pair<String, Template> bestEffort = new ImmutablePair<String, Template>("ResourceQuota-BestEffort", cfg.getTemplate("ResourceQuota-BestEffort.ftlh"));
    Pair<String, Template> notTerminatingAndNotBestEffort = new ImmutablePair<String, Template>("ResourceQuota-NotTerminating-And-NotBestEffort",
                                                                              cfg.getTemplate("ResourceQuota-NotTerminating-And-NotBestEffort.ftlh"));
    Pair<String, Template> terminating = new ImmutablePair<String, Template>("ResourceQuota-Terminating", cfg.getTemplate("ResourceQuota-Terminating.ftlh"));

    templates = Arrays.asList(clusterResourceQuota, bestEffortResourceLimits, burstableResourceLimits, maxImageCounts, bestEffort, notTerminatingAndNotBestEffort, terminating);
}
 
开发者ID:garethahealy,项目名称:quota-limits-generator,代码行数:21,代码来源:YamlTemplateProcessor.java

示例4: getConfigurationByClass

/**
 * 根据根路径的类,获取配置文件
 * @author nan.li
 * @param paramClass
 * @param prefix
 * @return
 */
public static Configuration getConfigurationByClass(Class<?> paramClass, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassForTemplateLoading(paramClass, prefix);
        //等价于下面这种方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:27,代码来源:FreeMkKit.java

示例5: getConfigurationByClassLoader

public static Configuration getConfigurationByClassLoader(ClassLoader classLoader, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassLoaderForTemplateLoading(classLoader, prefix);
        //等价于下面这种方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:20,代码来源:FreeMkKit.java

示例6: getConfigurationByDirectory

/**
 * 根据模板的路径,获取一个配置文件
 * @author [email protected]
 * @param templateLoadingPath
 * @return
 */
public static Configuration getConfigurationByDirectory(File templateLoadingPath)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        
        //以下这两种设置方式是等价的
        //            configuration.setDirectoryForTemplateLoading(templateLoadingPath);
        configuration.setTemplateLoader(new FileTemplateLoader(templateLoadingPath));
        
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:28,代码来源:FreeMkKit.java

示例7: replace

private String replace(String variableString, Object data) {
    String result;

    // 1. process proxy
    StringWriter writer = new StringWriter();
    try {
        freemarker.template.Template t = new freemarker.template.Template(variableString, variableString, new Configuration(Configuration.VERSION_2_3_25));
        t.process(data, writer);
    } catch (TemplateException | IOException e) {
        log.error("Could not replace proxy pattern");
    }
    result = writer.toString();

    // 2. slugify
    Slugify slg = new Slugify();
    result = slg.slugify(result);

    return result;
}
 
开发者ID:marcobehler,项目名称:saito,代码行数:19,代码来源:TemplateProcessor.java

示例8: configuration

@Singleton
@Provides
public static Configuration configuration(LinkHelper linkHelper, MultiTemplateLoader templateLoader) {
    try {
        freemarker.log.Logger.selectLoggerLibrary(Logger.LIBRARY_SLF4J);
        Configuration cfg = new freemarker.template.Configuration(Configuration.VERSION_2_3_25);
        cfg.setTagSyntax(freemarker.template.Configuration.SQUARE_BRACKET_TAG_SYNTAX);
        cfg.setLazyAutoImports(true);
        cfg.setLocale(Locale.GERMANY); // todo make configurable
        cfg.addAutoImport("saito", "saito.ftl");
        cfg.setSharedVariable("saitoLinkHelper", linkHelper);
        cfg.setDefaultEncoding("UTF-8");
        cfg.setLogTemplateExceptions(false);
        cfg.setTemplateLoader(templateLoader);
        return cfg;
    } catch (TemplateModelException | ClassNotFoundException e) {
        log.error("Error creating config", e);
        throw new IllegalStateException(e);
    }
}
 
开发者ID:marcobehler,项目名称:saito,代码行数:20,代码来源:FreemarkerModule.java

示例9: init

private void init() {
	if (inited) {
		return;
	}
	lock.lock();
	try {
		if (!inited) {
			cfg = new Configuration(Configuration.VERSION_2_3_25);
			cfg.setDefaultEncoding(encode);
			cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			cfg.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(), tmplPath);
		}
	} finally {
		lock.unlock();
	}
}
 
开发者ID:kanven,项目名称:schedule,代码行数:16,代码来源:TmplMarker.java

示例10: TemplateService

public TemplateService() {

		String templatePath = new File("").getAbsolutePath();
		System.out.println("Using template path '" + templatePath + "'.");
		
		try {
			config = new Configuration(Configuration.VERSION_2_3_25);
			config.setDirectoryForTemplateLoading(new File(templatePath));
			config.setDefaultEncoding("UTF-8");
			config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			config.setLogTemplateExceptions(false);
		} catch (IOException e) {
			throw new FileLibraryException(e);
		}
		
	}
 
开发者ID:dvanherbergen,项目名称:robotframework-filelibrary,代码行数:16,代码来源:TemplateService.java

示例11: processIndexPageTemplate

private void processIndexPageTemplate(ProjectDescriptor projectDescriptor, CustomData customData) throws IOException, URISyntaxException, TemplateException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "template");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);
    Map<String, Object> root = new HashMap<String, Object>();
    root.put("project", projectDescriptor);
    root.put("customData", customData);
    Template template = cfg.getTemplate("index.ftl");
    template.process(root, new FileWriter(new File(outputDir, "index.html")));
}
 
开发者ID:gradle-guides,项目名称:gradle-site-plugin,代码行数:12,代码来源:FreemarkerSiteGenerator.java

示例12: createFreemarkerConfig

public Configuration createFreemarkerConfig() throws IOException {
    final Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    final File templateDirectory = findTemplateDirectory();
    cfg.setDirectoryForTemplateLoading(templateDirectory);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
    cfg.setLogTemplateExceptions(false);

    return cfg;
}
 
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:10,代码来源:EmailEngine.java

示例13: createConfiguration

private static Configuration createConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
  configuration.setClassForTemplateLoading(Templates.class, "/templates/appengine");
  configuration.setDefaultEncoding(StandardCharsets.UTF_8.name());
  configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  configuration.setLogTemplateExceptions(false);
  return configuration;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:8,代码来源:Templates.java

示例14: replacePattern

private String replacePattern(String variableString, Object data) {
    String result;

    // 1. process proxy
    StringWriter writer = new StringWriter();
    try {
        freemarker.template.Template t = new freemarker.template.Template(variableString, variableString, new Configuration(Configuration.VERSION_2_3_25));
        t.process(data, writer);
    } catch (TemplateException | IOException e) {
        e.printStackTrace();
    }
    return writer.toString();
}
 
开发者ID:marcobehler,项目名称:saito,代码行数:13,代码来源:FrontMatter.java


注:本文中的freemarker.template.Configuration.VERSION_2_3_25属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。