Search in sources :

Example 1 with NonCacheableCacheEntryValidity

use of org.thymeleaf.cache.NonCacheableCacheEntryValidity in project thymeleaf-tests by thymeleaf.

the class TestTemplateResolver method resolveTemplate.

public TemplateResolution resolveTemplate(final IEngineConfiguration configuration, final String ownerTemplate, final String template, final Map<String, Object> templateResolutionAttributes) {
    final int placeholderPos = this.template.indexOf("{%%}");
    final String resource = this.template.substring(0, placeholderPos) + template + this.template.substring(placeholderPos + 4);
    final ITemplateResource templateResource = new StringTemplateResource(resource);
    final TemplateResolution templateResolution = new TemplateResolution(templateResource, // For the sake of these tests, considering resource existence verified is fine
    true, TemplateMode.HTML, false, new NonCacheableCacheEntryValidity());
    return templateResolution;
}
Also used : StringTemplateResource(org.thymeleaf.templateresource.StringTemplateResource) TemplateResolution(org.thymeleaf.templateresolver.TemplateResolution) ITemplateResource(org.thymeleaf.templateresource.ITemplateResource) NonCacheableCacheEntryValidity(org.thymeleaf.cache.NonCacheableCacheEntryValidity)

Example 2 with NonCacheableCacheEntryValidity

use of org.thymeleaf.cache.NonCacheableCacheEntryValidity in project thymeleaf-tests by thymeleaf.

the class TemplateParserTest method createOutput.

private String createOutput(final Document document) throws IOException {
    final TemplateProcessingParameters templateProcessingParameters = new TemplateProcessingParameters(this.configuration, "test", new Context());
    final TemplateResolution templateResolution = new TemplateResolution("test", "test", new ClassLoaderResourceResolver(), "UTF-8", "XHTML", new NonCacheableCacheEntryValidity());
    final Arguments arguments = new Arguments(new TemplateEngine(), templateProcessingParameters, templateResolution, new TemplateRepository(this.configuration), document);
    final StringWriter stringWriter = new StringWriter();
    final ITemplateWriter templateWriter = this.configuration.getTemplateModeHandler("XHTML").getTemplateWriter();
    templateWriter.write(arguments, stringWriter, document);
    return stringWriter.toString();
}
Also used : Context(org.thymeleaf.context.Context) TemplateEngine(org.thymeleaf.TemplateEngine) TemplateRepository(org.thymeleaf.TemplateRepository) TemplateProcessingParameters(org.thymeleaf.TemplateProcessingParameters) StringWriter(java.io.StringWriter) TemplateResolution(org.thymeleaf.templateresolver.TemplateResolution) Arguments(org.thymeleaf.Arguments) ITemplateWriter(org.thymeleaf.templatewriter.ITemplateWriter) ClassLoaderResourceResolver(org.thymeleaf.resourceresolver.ClassLoaderResourceResolver) NonCacheableCacheEntryValidity(org.thymeleaf.cache.NonCacheableCacheEntryValidity)

Example 3 with NonCacheableCacheEntryValidity

use of org.thymeleaf.cache.NonCacheableCacheEntryValidity in project thymeleaf-tests by thymeleaf.

the class TestTemplateResolver method resolveTemplate.

public TemplateResolution resolveTemplate(final TemplateProcessingParameters templateProcessingParameters) {
    final String templateName = templateProcessingParameters.getTemplateName();
    final int placeholderPos = this.template.indexOf("{%%}");
    final String result = this.template.substring(0, placeholderPos) + templateName + this.template.substring(placeholderPos + 4);
    final IResourceResolver resourceResolver = new TestResourceResolver(result);
    final TemplateResolution templateResolution = new TemplateResolution(templateName, "TEST", resourceResolver, "UTF-8", "HTML5", new NonCacheableCacheEntryValidity());
    return templateResolution;
}
Also used : IResourceResolver(org.thymeleaf.resourceresolver.IResourceResolver) TemplateResolution(org.thymeleaf.templateresolver.TemplateResolution) NonCacheableCacheEntryValidity(org.thymeleaf.cache.NonCacheableCacheEntryValidity)

Aggregations

NonCacheableCacheEntryValidity (org.thymeleaf.cache.NonCacheableCacheEntryValidity)3 TemplateResolution (org.thymeleaf.templateresolver.TemplateResolution)3 StringWriter (java.io.StringWriter)1 Arguments (org.thymeleaf.Arguments)1 TemplateEngine (org.thymeleaf.TemplateEngine)1 TemplateProcessingParameters (org.thymeleaf.TemplateProcessingParameters)1 TemplateRepository (org.thymeleaf.TemplateRepository)1 Context (org.thymeleaf.context.Context)1 ClassLoaderResourceResolver (org.thymeleaf.resourceresolver.ClassLoaderResourceResolver)1 IResourceResolver (org.thymeleaf.resourceresolver.IResourceResolver)1 ITemplateResource (org.thymeleaf.templateresource.ITemplateResource)1 StringTemplateResource (org.thymeleaf.templateresource.StringTemplateResource)1 ITemplateWriter (org.thymeleaf.templatewriter.ITemplateWriter)1