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


Java TemplateEngine.createTemplate方法代码示例

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


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

示例1: getTemplate

import groovy.text.TemplateEngine; //导入方法依赖的package包/类
private static Template getTemplate(TemplateEngine engine, String name)
		throws CompilationFailedException, ClassNotFoundException, IOException {

	File file = new File("templates", name);
	if (file.exists()) {
		return engine.createTemplate(file);
	}

	ClassLoader classLoader = GroovyTemplate.class.getClassLoader();
	URL resource = classLoader.getResource("templates/" + name);
	if (resource != null) {
		return engine.createTemplate(resource);
	}

	return engine.createTemplate(name);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:GroovyTemplate.java

示例2: findTemplate

import groovy.text.TemplateEngine; //导入方法依赖的package包/类
private Template findTemplate(final String templateName) throws SAXException, ParserConfigurationException, ClassNotFoundException, IOException {
    TemplateEngine ste = templateName.endsWith(".gxml") ? new XmlTemplateEngine() : new SimpleTemplateEngine();
    File sourceTemplate = new File(templatesPath, templateName);
    Template template = cachedTemplates.get(templateName);
    if (template == null) {
        template = ste.createTemplate(new InputStreamReader(new BufferedInputStream(new FileInputStream(sourceTemplate)), config.getString(Keys.TEMPLATE_ENCODING)));
        cachedTemplates.put(templateName, template);
    }
    return template;
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:11,代码来源:GroovyTemplateEngine.java

示例3: initialize

import groovy.text.TemplateEngine; //导入方法依赖的package包/类
private void initialize() throws GrafikonException {
    TemplateEngine engine = new SimpleTemplateEngine();
    try {
        templateGString = engine.createTemplate(this.getTemplate());
    } catch (Exception e) {
        throw new GrafikonException("Cannot create template: " + e.getMessage(), e, GrafikonException.Type.TEXT_TEMPLATE);
    }
}
 
开发者ID:jub77,项目名称:grafikon,代码行数:9,代码来源:TextTemplateGroovy.java

示例4: setupUsers

import groovy.text.TemplateEngine; //导入方法依赖的package包/类
protected void setupUsers() {
	try {
		TemplateEngine engine = new SimpleTemplateEngine();
		Template secTemplate = engine.createTemplate(ApplicationWizard.class.getResource("Security.groovy"));
		Map<String, String> bindings = new HashMap<String, String>();
		bindings.put("databaseName", connectionProvider.getDatabase().getDatabaseName());
		bindings.put("userTableEntityName", userTable.getActualEntityName());
		bindings.put("userIdProperty", userIdProperty);
		bindings.put("userNameProperty", userNameProperty);
		bindings.put("passwordProperty", userPasswordProperty);
		bindings.put("userEmailProperty", userEmailProperty);
		bindings.put("userTokenProperty", userTokenProperty);

		bindings.put("groupTableEntityName", groupTable != null ? groupTable.getActualEntityName() : "");
		bindings.put("groupIdProperty", StringUtils.defaultString(groupIdProperty));
		bindings.put("groupNameProperty", StringUtils.defaultString(groupNameProperty));

		bindings.put("userGroupTableEntityName", userGroupTable != null ? userGroupTable.getActualEntityName() : "");
		bindings.put("groupLinkProperty", StringUtils.defaultString(groupLinkProperty));
		bindings.put("userLinkProperty", StringUtils.defaultString(userLinkProperty));
		bindings.put("adminGroupName", StringUtils.defaultString(adminGroupName));

		bindings.put("encryptionAlgorithm", encryptionAlgorithm);
		File gcp = (File) context.getServletContext().getAttribute(BaseModule.GROOVY_CLASS_PATH);
		FileWriter fw = new FileWriter(new File(gcp, "Security.groovy"));
		secTemplate.make(bindings).writeTo(fw);
		IOUtils.closeQuietly(fw);
	} catch (Exception e) {
		logger.warn("Couldn't configure users", e);
		SessionMessages.addWarningMessage(ElementsThreadLocals.getText("couldnt.set.up.user.management._", e));
	}
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:33,代码来源:ApplicationWizard.java

示例5: setupUsers

import groovy.text.TemplateEngine; //导入方法依赖的package包/类
protected void setupUsers() {
    try {
        TemplateEngine engine = new SimpleTemplateEngine();
        Template secTemplate = engine.createTemplate(ApplicationWizard.class.getResource("Security.groovy"));
        Map<String, String> bindings = new HashMap<String, String>();
        bindings.put("databaseName", connectionProvider.getDatabase().getDatabaseName());
        bindings.put("userTableEntityName", userTable.getActualEntityName());
        bindings.put("userIdProperty", userIdProperty);
        bindings.put("userNameProperty", userNameProperty);
        bindings.put("passwordProperty", userPasswordProperty);
        bindings.put("userEmailProperty", userEmailProperty);
        bindings.put("userTokenProperty", userTokenProperty);

        bindings.put("groupTableEntityName",
                groupTable != null ? groupTable.getActualEntityName() : "");
        bindings.put("groupIdProperty", StringUtils.defaultString(groupIdProperty));
        bindings.put("groupNameProperty", StringUtils.defaultString(groupNameProperty));

        bindings.put("userGroupTableEntityName",
                userGroupTable != null ? userGroupTable.getActualEntityName() : "");
        bindings.put("groupLinkProperty", StringUtils.defaultString(groupLinkProperty));
        bindings.put("userLinkProperty", StringUtils.defaultString(userLinkProperty));
        bindings.put("adminGroupName", StringUtils.defaultString(adminGroupName));

        bindings.put("hashIterations", "1");
        String[] algoAndEncoding = encryptionAlgorithm.split(":");
        bindings.put("hashAlgorithm", '"' + algoAndEncoding[0] + '"');
        if(algoAndEncoding[1].equals("plaintext")) {
            bindings.put("hashFormat", "null");
        } else if(algoAndEncoding[1].equals("hex")) {
            bindings.put("hashFormat", "new org.apache.shiro.crypto.hash.format.HexFormat()");
        } else if(algoAndEncoding[1].equals("base64")) {
            bindings.put("hashFormat", "new org.apache.shiro.crypto.hash.format.Base64Format()");
        }
        File gcp = (File) context.getServletContext().getAttribute(BaseModule.GROOVY_CLASS_PATH);
        FileWriter fw = new FileWriter(new File(gcp, "Security.groovy"));
        secTemplate.make(bindings).writeTo(fw);
        IOUtils.closeQuietly(fw);
    } catch (Exception e) {
        logger.warn("Couldn't configure users", e);
        SessionMessages.addWarningMessage(ElementsThreadLocals.getText("couldnt.set.up.user.management._", e));
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:44,代码来源:ApplicationWizard.java


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