Search in sources :

Example 1 with OutputTemplateHandler

use of org.thymeleaf.engine.OutputTemplateHandler in project thymeleaf-tests by thymeleaf.

the class HtmlBlockSelectorMarkupHandlerTest method check.

private static void check(final HTMLTemplateParser parser, final IEngineConfiguration templateEngineContext, final String templateName, final String input, final String output, final Set<String> blockSelectors) throws Exception {
    final StringWriter writer = new StringWriter();
    final ITemplateHandler handler = new OutputTemplateHandler(writer);
    parser.parseStandalone(templateEngineContext, templateName, templateName, blockSelectors, new StringTemplateResource(input), TemplateMode.HTML, false, handler);
    assertEquals("Test failed for file: " + templateName, output, writer.toString());
}
Also used : ITemplateHandler(org.thymeleaf.engine.ITemplateHandler) StringTemplateResource(org.thymeleaf.templateresource.StringTemplateResource) StringWriter(java.io.StringWriter) OutputTemplateHandler(org.thymeleaf.engine.OutputTemplateHandler)

Example 2 with OutputTemplateHandler

use of org.thymeleaf.engine.OutputTemplateHandler in project thymeleaf-tests by thymeleaf.

the class HtmlBlockSelectorMarkupHandlerTest method check.

private static void check(final HTMLTemplateParser parser, final IEngineConfiguration templateEngineContext, final String templateName, final String input, final String output, final String[] blockSelectors) throws Exception {
    final StringWriter writer = new StringWriter();
    final ITemplateHandler handler = new OutputTemplateHandler(writer);
    handler.setProcessingContext(StandardProcessingContextFactory.build(TEMPLATE_ENGINE_CONFIGURATION, templateName, TemplateMode.HTML, new Context(Locale.US)));
    parser.parse(templateEngineContext, TemplateMode.HTML, new StringResource(templateName, input), blockSelectors, handler);
    assertEquals("Test failed for file: " + templateName, output, writer.toString());
}
Also used : Context(org.thymeleaf.context.Context) ITemplateHandler(org.thymeleaf.engine.ITemplateHandler) StringResource(org.thymeleaf.resource.StringResource) StringWriter(java.io.StringWriter) OutputTemplateHandler(org.thymeleaf.engine.OutputTemplateHandler)

Aggregations

StringWriter (java.io.StringWriter)2 ITemplateHandler (org.thymeleaf.engine.ITemplateHandler)2 OutputTemplateHandler (org.thymeleaf.engine.OutputTemplateHandler)2 Context (org.thymeleaf.context.Context)1 StringResource (org.thymeleaf.resource.StringResource)1 StringTemplateResource (org.thymeleaf.templateresource.StringTemplateResource)1