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


Java MarkupTemplateEngine类代码示例

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


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


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