Search in sources :

Example 1 with StringResource

use of org.thymeleaf.resource.StringResource in project thymeleaf-tests by thymeleaf.

the class CloseElementTagTest method computeHtmlTag.

private static ICloseElementTag computeHtmlTag(final String input) {
    final String templateName = "test";
    final TagObtentionTemplateHandler handler = new TagObtentionTemplateHandler();
    HTML_PARSER.parse(TEMPLATE_ENGINE_CONFIGURATION, TemplateMode.HTML, new StringResource(templateName, input), handler);
    return handler.tag;
}
Also used : StringResource(org.thymeleaf.resource.StringResource)

Example 2 with StringResource

use of org.thymeleaf.resource.StringResource 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)

Example 3 with StringResource

use of org.thymeleaf.resource.StringResource in project thymeleaf-tests by thymeleaf.

the class BareHtmlEngineTest method check.

private static void check(final String input, final String output, final String[] blockSelectors) throws Exception {
    final String templateName = "test";
    final StringWriter writer = new StringWriter();
    final ITemplateHandler handler = new OutputTemplateHandler(writer);
    handler.setProcessingContext(new ProcessingContext(TEMPLATE_ENGINE_CONFIGURATION, templateName, TemplateMode.HTML, Locale.US, null));
    if (blockSelectors != null) {
        PARSER.parse(TEMPLATE_ENGINE_CONFIGURATION, TemplateMode.HTML, new StringResource(templateName, input), blockSelectors, handler);
    } else {
        PARSER.parse(TEMPLATE_ENGINE_CONFIGURATION, TemplateMode.HTML, new StringResource(templateName, input), handler);
    }
    Assert.assertEquals("Test failed for file: " + templateName, output, writer.toString());
}
Also used : ProcessingContext(org.thymeleaf.context.ProcessingContext) StringResource(org.thymeleaf.resource.StringResource) StringWriter(java.io.StringWriter)

Example 4 with StringResource

use of org.thymeleaf.resource.StringResource in project thymeleaf-tests by thymeleaf.

the class CloseElementTagTest method computeXmlTag.

private static ICloseElementTag computeXmlTag(final String input) {
    final String templateName = "test";
    final TagObtentionTemplateHandler handler = new TagObtentionTemplateHandler();
    XML_PARSER.parse(TEMPLATE_ENGINE_CONFIGURATION, TemplateMode.XML, new StringResource(templateName, input), handler);
    return handler.tag;
}
Also used : StringResource(org.thymeleaf.resource.StringResource)

Example 5 with StringResource

use of org.thymeleaf.resource.StringResource in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method computeXmlTag.

private static TagObtentionTemplateHandler computeXmlTag(final String input, final Set<IDialect> dialects) {
    final String templateName = "test";
    final TagObtentionTemplateHandler handler = new TagObtentionTemplateHandler();
    final IEngineConfiguration templateEngineContext = TestTemplateEngineConfigurationBuilder.build(dialects);
    XML_PARSER.parse(templateEngineContext, TemplateMode.XML, new StringResource(templateName, input), handler);
    return handler;
}
Also used : StringResource(org.thymeleaf.resource.StringResource) IEngineConfiguration(org.thymeleaf.IEngineConfiguration)

Aggregations

StringResource (org.thymeleaf.resource.StringResource)12 StringWriter (java.io.StringWriter)2 IEngineConfiguration (org.thymeleaf.IEngineConfiguration)2 Context (org.thymeleaf.context.Context)1 ProcessingContext (org.thymeleaf.context.ProcessingContext)1 ITemplateHandler (org.thymeleaf.engine.ITemplateHandler)1 OutputTemplateHandler (org.thymeleaf.engine.OutputTemplateHandler)1