• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MarkupTemplateEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中groovy.text.markup.MarkupTemplateEngine的典型用法代码示例。如果您正苦于以下问题:Java MarkupTemplateEngine类的具体用法?Java MarkupTemplateEngine怎么用?Java MarkupTemplateEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: resolveTemplate

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
/**
 * Resolve a template from the given template path.
 * <p>The default implementation uses the Locale associated with the current request,
 * as obtained through {@link org.springframework.context.i18n.LocaleContextHolder LocaleContextHolder},
 * to find the template file. Effectively the locale configured at the engine level is ignored.
 * @see LocaleContextHolder
 * @see #setLocale
 */
protected URL resolveTemplate(ClassLoader classLoader, String templatePath) throws IOException {
	MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(templatePath);
	Locale locale = LocaleContextHolder.getLocale();
	URL url = classLoader.getResource(resource.withLocale(locale.toString().replace("-", "_")).toString());
	if (url == null) {
		url = classLoader.getResource(resource.withLocale(locale.getLanguage()).toString());
	}
	if (url == null) {
		url = classLoader.getResource(resource.withLocale(null).toString());
	}
	if (url == null) {
		throw new IOException("Unable to load template:" + templatePath);
	}
	return url;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:GroovyMarkupConfigurer.java


示例2: isUsingGroovyAllJar

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
/**
 * MarkupTemplateEngine could be loaded from groovy-templates or groovy-all.
 * Unfortunately it's quite common for people to use groovy-all and not actually
 * need templating support. This method check attempts to check the source jar so
 * that we can skip the {@code /template} folder check for such cases.
 * @return true if the groovy-all jar is used
 */
private boolean isUsingGroovyAllJar() {
	try {
		ProtectionDomain domain = MarkupTemplateEngine.class
				.getProtectionDomain();
		CodeSource codeSource = domain.getCodeSource();
		if (codeSource != null
				&& codeSource.getLocation().toString().contains("-all")) {
			return true;
		}
		return false;
	}
	catch (Exception ex) {
		return false;
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:GroovyTemplateAutoConfiguration.java


示例3: resolveTemplate

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
@Override
public URL resolveTemplate(final String templatePath) throws IOException {
	MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
			.parse(templatePath);
	URL resource = this.templateClassLoader.getResource(templateResource
			.withLocale(LocaleContextHolder.getLocale().toString().replace("-", "_"))
			.toString());
	if (resource == null) {
		// no resource found with the default locale, try without any locale
		resource = this.templateClassLoader
				.getResource(templateResource.withLocale(null).toString());
	}
	if (resource == null) {
		throw new IOException("Unable to load template:" + templatePath);
	}
	return resource;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:GroovyTemplateResolver.java


示例4: autodetectMarkupTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
/**
 * Autodetect a MarkupTemplateEngine via the ApplicationContext.
 * Called if a MarkupTemplateEngine has not been manually configured.
 */
protected MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansException {
	try {
		return BeanFactoryUtils.beanOfTypeIncludingAncestors(getApplicationContext(),
				GroovyMarkupConfig.class, true, false).getTemplateEngine();
	}
	catch (NoSuchBeanDefinitionException ex) {
		throw new ApplicationContextException("Expected a single GroovyMarkupConfig bean in the current " +
				"Servlet web application context or the parent root context: GroovyMarkupConfigurer is " +
				"the usual implementation. This bean may have any name.", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:GroovyMarkupView.java


示例5: createTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
protected MarkupTemplateEngine createTemplateEngine() throws IOException {
	if (this.templateEngine == null) {
		ClassLoader templateClassLoader = createTemplateClassLoader();
		this.templateEngine = new MarkupTemplateEngine(templateClassLoader, this, new LocaleTemplateResolver());
	}
	return this.templateEngine;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:GroovyMarkupConfigurer.java


示例6: defaultTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
@Test
public void defaultTemplateEngine() throws Exception {
	this.configurer.setApplicationContext(this.applicationContext);
	this.configurer.afterPropertiesSet();

	TemplateEngine engine = this.configurer.getTemplateEngine();
	assertNotNull(engine);
	assertEquals(MarkupTemplateEngine.class, engine.getClass());

	MarkupTemplateEngine markupEngine = (MarkupTemplateEngine) engine;
	TemplateConfiguration configuration = markupEngine.getTemplateConfiguration();
	assertNotNull(configuration);
	assertEquals(GroovyMarkupConfigurer.class, configuration.getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:GroovyMarkupConfigurerTests.java


示例7: customTemplateConfiguration

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
@Test
public void customTemplateConfiguration() throws Exception {
	this.configurer.setApplicationContext(this.applicationContext);
	this.configurer.setCacheTemplates(false);
	this.configurer.afterPropertiesSet();

	TemplateEngine engine = this.configurer.getTemplateEngine();
	assertNotNull(engine);
	assertEquals(MarkupTemplateEngine.class, engine.getClass());

	MarkupTemplateEngine markupEngine = (MarkupTemplateEngine) engine;
	TemplateConfiguration configuration = markupEngine.getTemplateConfiguration();
	assertNotNull(configuration);
	assertFalse(configuration.isCacheTemplates());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:GroovyMarkupConfigurerTests.java


示例8: GroovyMarkupConfiguration

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
public GroovyMarkupConfiguration(ApplicationContext applicationContext,
		GroovyTemplateProperties properties,
		ObjectProvider<MarkupTemplateEngine> templateEngineProvider) {
	this.applicationContext = applicationContext;
	this.properties = properties;
	this.templateEngine = templateEngineProvider.getIfAvailable();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:GroovyTemplateAutoConfiguration.java


示例9: renderTemplate

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
@Test
public void renderTemplate() throws Exception {
	registerAndRefreshContext();
	GroovyMarkupConfig config = this.context.getBean(GroovyMarkupConfig.class);
	MarkupTemplateEngine engine = config.getTemplateEngine();
	Writer writer = new StringWriter();
	engine.createTemplate(new ClassPathResource("templates/message.tpl").getFile())
			.make(new HashMap<String, Object>(
					Collections.singletonMap("greeting", "Hello World")))
			.writeTo(writer);
	assertThat(writer.toString()).contains("Hello World");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:GroovyTemplateAutoConfigurationTests.java


示例10: GroovyMarkupTemplateGenerator

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
public GroovyMarkupTemplateGenerator(final String template) {
    try {
        this.template = new MarkupTemplateEngine().createTemplate(template);
    } catch (ClassNotFoundException | IOException e) {
        throw new BootException(e);
    }
    this.templateText = template;
}
 
开发者ID:sql-boot,项目名称:sql-boot,代码行数:9,代码来源:GroovyMarkupTemplateGenerator.java


示例11: renderTemplate

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
@Test
public void renderTemplate() throws Exception {
	registerAndRefreshContext();
	GroovyMarkupConfig config = this.context.getBean(GroovyMarkupConfig.class);
	MarkupTemplateEngine engine = config.getTemplateEngine();
	Writer writer = new StringWriter();
	engine.createTemplate(new ClassPathResource("templates/message.tpl").getFile())
			.make(new HashMap<String, Object>(
					Collections.singletonMap("greeting", "Hello World")))
			.writeTo(writer);
	assertThat(writer.toString(), containsString("Hello World"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:GroovyTemplateAutoConfigurationTests.java


示例12: getEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
public MarkupTemplateEngine getEngine(Locale locale) {
    String localeString = locale.toString();
    MarkupTemplateEngine engine = engines.get(localeString);
    if (engine!=null) {
        return engine;
    }
    return lazyLoadEngine(locale);
}
 
开发者ID:melix,项目名称:spring-groovymarkup,代码行数:9,代码来源:LocaleAwareEngineFactory.java


示例13: init

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
@Override
public void init(Application application) {
    super.init(application);

    PippoSettings pippoSettings = getPippoSettings();

    TemplateConfiguration configuration = new TemplateConfiguration();
    configuration.setBaseTemplateClass(PippoGroovyTemplate.class);
    configuration.setAutoEscape(true);

    if (pippoSettings.isDev()) {
        // Do not cache templates in dev mode
        configuration.setCacheTemplates(false);
    } else {
        configuration.setAutoIndent(true);
        configuration.setAutoNewLine(true);
        configuration.setAutoIndentString("  ");
    }

    String pathPrefix = getTemplatePathPrefix();
    pathPrefix = StringUtils.removeStart(pathPrefix, "/");
    pathPrefix = StringUtils.removeEnd(pathPrefix, "/");

    GroovyTemplateResolver cachingResolver = new GroovyTemplateResolver(pathPrefix);

    ClassLoader classLoader = getClass().getClassLoader();

    // allow custom initialization
    init(application, configuration);

    engine = new MarkupTemplateEngine(classLoader, configuration, cachingResolver);
}
 
开发者ID:decebals,项目名称:pippo,代码行数:33,代码来源:GroovyTemplateEngine.java


示例14: PippoGroovyTemplate

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
public PippoGroovyTemplate(final MarkupTemplateEngine templateEngine, final Map model,
        final Map<String, String> modelTypes, final TemplateConfiguration configuration) {
    super(templateEngine, model, modelTypes, configuration);

    this.modelTypes = modelTypes;
    this.engine = templateEngine;
    this.webjarsPatternRef = new AtomicReference<>();
    this.publicPatternRef = new AtomicReference<>();
}
 
开发者ID:decebals,项目名称:pippo,代码行数:10,代码来源:PippoGroovyTemplate.java


示例15: initializeTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
private void initializeTemplateEngine() {
    templateEngine = new MarkupTemplateEngine(MarkupTemplateEngine.class.getClassLoader(),templatesPath,templateConfiguration);
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:4,代码来源:GroovyMarkupTemplateEngine.java


示例16: getTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
public MarkupTemplateEngine getTemplateEngine() {
	return templateEngine;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:GroovyMarkupConfigurer.java


示例17: CustomBaseTemplate

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
public CustomBaseTemplate(
        final MarkupTemplateEngine templateEngine,
        final Map model,
        final Map modelTypes, final TemplateConfiguration configuration) {
    super(templateEngine, model, modelTypes, configuration);
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:CustomBaseTemplate.java


示例18: createTemplatePath

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
private String createTemplatePath(final String viewName, final Locale locale) {
    MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(viewName);
    resource.withLocale(locale.toString().replace("-", "_"));
    return resource.toString();
}
 
开发者ID:melix,项目名称:spring-groovymarkup,代码行数:6,代码来源:MarkupTemplateViewResolver.java


示例19: setTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
/**
 * Set the MarkupTemplateEngine to use in this view.
 * <p>If not set, the engine is auto-detected by looking up up a single
 * {@link GroovyMarkupConfig} bean in the web application context and using
 * it to obtain the configured {@code MarkupTemplateEngine} instance.
 * @see GroovyMarkupConfig
 */
public void setTemplateEngine(MarkupTemplateEngine engine) {
	this.engine = engine;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:GroovyMarkupView.java


示例20: getTemplateEngine

import groovy.text.markup.MarkupTemplateEngine; //导入依赖的package包/类
/**
 * Return the Groovy {@link MarkupTemplateEngine} for the current
 * web application context. May be unique to one servlet, or shared
 * in the root context.
 * @return the Groovy MarkupTemplateEngine engine
 */
MarkupTemplateEngine getTemplateEngine();
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:GroovyMarkupConfig.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFPortStateSerializerVer10类代码示例发布时间:2022-05-22
下一篇:
Java Pattern类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap