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


Java Configuration.setDirectoryForTemplateLoading方法代码示例

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


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

示例1: initConfig

import freemarker.template.Configuration; //导入方法依赖的package包/类
@PostConstruct
public void initConfig() throws Exception {
    Configuration configuration = new Configuration();
    File file = new File(servletContext.getRealPath("/WEB-INF/layouts"));
    configuration.setDirectoryForTemplateLoading(file);
    configuration.setDefaultEncoding("UTF-8");
    this.template = configuration.getTemplate("email.template");
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:9,代码来源:NoticeService.java

示例2: generateResumeHTML

import freemarker.template.Configuration; //导入方法依赖的package包/类
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,代码行数:21,代码来源:ResumeGenerator.java

示例3: writeCommandCards

import freemarker.template.Configuration; //导入方法依赖的package包/类
private IStatus writeCommandCards(boolean obsRefreshFlag, String templateInputDirectory, String templateOutputDirectory) {
	Writer playerArmyFile = null;
	try {
		Configuration config = us.nineworlds.xstreamer.core.Activator.getDefault().getFreemarkerConfig();
		config.setDirectoryForTemplateLoading(new File(templateInputDirectory));
		
		java.nio.file.Path jpath = java.nio.file.Paths.get(templateFilename);
		Template armyTemplate = config.getTemplate(jpath.getFileName().toString());
		playerArmyFile = new FileWriter(new File(templateOutputDirectory + File.separator + commandFilename));

		Map<String, Object> input = new HashMap<>();

		input.put("iaspec", iaspec);
		input.put("allDeployments", Activator.getDefault().getDeploymentsLookup().getDeployments());
		input.put("allCommandCards", Activator.getDefault().getCommandCardLookup().getCommandCards());
		input.put("obs_refresh", obsRefreshFlag);

		armyTemplate.process(input, playerArmyFile);
	} catch (Exception e) {
		e.printStackTrace();
		return Status.CANCEL_STATUS;
	} finally {
		IOUtils.closeQuietly(playerArmyFile);			
	}
	return Status.OK_STATUS;
}
 
开发者ID:NineWorlds,项目名称:xstreamer,代码行数:27,代码来源:GenerateCommandJob.java

示例4: initializeConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
/**
 * Configures freemarker for usage.
 * @return
 * @throws URISyntaxException
 * @throws TemplateNotFoundException
 * @throws MalformedTemplateNameException
 * @throws ParseException
 * @throws IOException
 * @throws TemplateException
 */
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

	Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);
	
	Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();

	customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE);

	cfg.setCustomNumberFormats(customNumberFormats);

	return cfg;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:32,代码来源:DwFeatureModelSVGGenerator.java

示例5: initializeConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
	cfg.setDefaultEncoding("UTF-8");
	cfg.setLocale(Locale.US);
	cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
	
	Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
	customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);
	
	cfg.setCustomDateFormats(customDateFormats);
	cfg.setDateTimeFormat("@simle");

	Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
	URL fileURL = bundle.getEntry("templates/");

	File file = new File(FileLocator.resolve(fileURL).toURI());
	cfg.setDirectoryForTemplateLoading(file);

	return cfg;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:22,代码来源:DwFeatureModelOverviewGenerator.java

示例6: TemplateService

import freemarker.template.Configuration; //导入方法依赖的package包/类
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,代码行数:17,代码来源:TemplateService.java

示例7: getTemplate

import freemarker.template.Configuration; //导入方法依赖的package包/类
/**
 * 获取模板
 * 
 * @param templateName
 *            模板名称(含后缀名)
 * @return Template
 * @throws IOException
 */
public static Template getTemplate(String templateName) throws IOException {
	Configuration cfg = new Configuration();
	Template temp = null;
	File tmpRootFile = getResource(templateName).getFile().getParentFile();
	if (tmpRootFile == null) {
		throw new RuntimeException("无法取得模板根路径!");
	}
	try {
		cfg.setDefaultEncoding("utf-8");
		cfg.setOutputEncoding("utf-8");
		cfg.setDirectoryForTemplateLoading(tmpRootFile);
		/* cfg.setDirectoryForTemplateLoading(getResourceURL()); */
		cfg.setObjectWrapper(new DefaultObjectWrapper());
		temp = cfg.getTemplate(templateName);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return temp;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:28,代码来源:FreeMarkerUtil.java

示例8: createTemplateConfiguration

import freemarker.template.Configuration; //导入方法依赖的package包/类
private void createTemplateConfiguration(final CompositeConfiguration config, final File templatesPath) {
    templateCfg = new Configuration();
    templateCfg.setDefaultEncoding(config.getString(Keys.RENDER_ENCODING));
    try {
        templateCfg.setDirectoryForTemplateLoading(templatesPath);
    } catch (IOException e) {
        e.printStackTrace();
    }
    templateCfg.setObjectWrapper(new DefaultObjectWrapper());
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:11,代码来源:FreemarkerTemplateEngine.java

示例9: testSpeedOfFreemarker

import freemarker.template.Configuration; //导入方法依赖的package包/类
public void testSpeedOfFreemarker() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setDirectoryForTemplateLoading(getWorkDir());
    cfg.setObjectWrapper(new BeansWrapper());
    Template templ = cfg.getTemplate("template.txt");
    
    for(int i = 0; i < whereTo.length; i++) {
        Writer out = new BufferedWriter(new FileWriter(whereTo[i]));
        templ.process(parameters, out);
        out.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SpeedTest.java

示例10: init

import freemarker.template.Configuration; //导入方法依赖的package包/类
@PostConstruct
public void init() throws IOException {
  try {
    cfg = new Configuration(Configuration.getVersion());
    cfg.setDirectoryForTemplateLoading(new File(templateLocation));
    cfg.setDefaultEncoding(templateEncoding);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  } catch (IOException e) {
    logger.error("Problem getting rule template location." + e.getMessage());
    throw e;
  }
}
 
开发者ID:edgexfoundry,项目名称:support-rulesengine,代码行数:13,代码来源:RuleCreator.java

示例11: generateUserDockerrunFile

import freemarker.template.Configuration; //导入方法依赖的package包/类
/**
 * Generate a dockerrun.aws.json file with a custom user template
 * @param dockerrunFilePath the location of the dockerrun template
 * @param dockerrunOutputDestination the output directory
 * @param parameters a map to hydrate the template with
 * @throws IOException if failed to load the template file
 * @throws TemplateException if template generation fails
 */
public static void generateUserDockerrunFile(
    String dockerrunFilePath,
    String dockerrunOutputDestination,
    Map<String, Object> parameters
) throws IOException, TemplateException {
  File templateFile = new File(dockerrunFilePath);
  Configuration cfg = initializeTemplateConfiguration();
  cfg.setDirectoryForTemplateLoading(templateFile.getParentFile());
  generateFileFromTemplate(cfg, templateFile.getName(), dockerrunOutputDestination, parameters);

}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:20,代码来源:FileGenerator.java

示例12: init

import freemarker.template.Configuration; //导入方法依赖的package包/类
@PostConstruct
public void init() throws IOException {
    configuration = new Configuration(Configuration.VERSION_2_3_21);

    File templateDir = new File(baseDir);
    templateDir.mkdirs();
    configuration.setDirectoryForTemplateLoading(templateDir);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:9,代码来源:FreemarkerTemplateService.java

示例13: init

import freemarker.template.Configuration; //导入方法依赖的package包/类
public void init() {
	try {
		configuration = new Configuration();
		File root = new File("");
		File absoluteFile = root.getAbsoluteFile();
		configuration.setDirectoryForTemplateLoading(new File(absoluteFile + "/FreeMakerTemplate"));
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:11,代码来源:FileLoad.java

示例14: processTemplate

import freemarker.template.Configuration; //导入方法依赖的package包/类
public static File processTemplate(File template) throws IOException, TemplateException {
    Configuration config = new Configuration();
    config.setDirectoryForTemplateLoading(template.getParentFile());
    config.setObjectWrapper(new DefaultObjectWrapper());
    config.setDefaultEncoding("UTF-8");
    Template temp = config.getTemplate(template.getName());
    String child = template.getName() + RandomStringUtils.randomAlphanumeric(8);
    File fileOutput = new File(template.getParentFile(), child);
    Writer fileWriter = new FileWriter(fileOutput);
    Map<Object, Object> currentSession = Thucydides.getCurrentSession();
    temp.process(currentSession, fileWriter);
    return fileOutput;
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:14,代码来源:TemplateUtils.java

示例15: prepareFreemarkerTemplate

import freemarker.template.Configuration; //导入方法依赖的package包/类
private File prepareFreemarkerTemplate(String filePath) throws IOException, TemplateException {
    File template = getFileFromResourcesByFilePath(filePath);
    Configuration config = new Configuration();
    config.setDirectoryForTemplateLoading(template.getParentFile());
    config.setObjectWrapper(new DefaultObjectWrapper());
    config.setDefaultEncoding("UTF-8");
    Template temp = config.getTemplate(template.getName());
    String child = template.getName() + RandomStringUtils.randomAlphanumeric(8);
    File fileOutput = new File(template.getParentFile(), child);
    Writer fileWriter = new FileWriter(fileOutput);
    Map<Object, Object> currentSession = Thucydides.getCurrentSession();
    temp.process(currentSession, fileWriter);
    return fileOutput;
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:15,代码来源:WebserviceSteps.java


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