Search in sources :

Example 6 with DialectConfiguration

use of org.thymeleaf.DialectConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation04.

@Test
public void testProcessorComputation04() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "TH", "N-ELEMENT-20-null-src, N-ELEMENT-10-null-src,N-ELEMENT-20-null-href,N-ELEMENT-20-null-text,N-ELEMENT-10-null-text,N-ELEMENT-10-*div-text,N-ELEMENT-15-*div-src,N-ELEMENT-1-form-*action,N-ELEMENT-20-form-null,N-ELEMENT-10-null-*action,N-ELEMENT-50-null-null", "N-ELEMENT-200-null-src, N-ELEMENT-100-null-src,N-ELEMENT-200-null-href,N-ELEMENT-200-null-text,N-ELEMENT-100-null-text,N-ELEMENT-100-*div-text,N-ELEMENT-150-*div-src,N-ELEMENT-10-form-*action,N-ELEMENT-200-form-null,N-ELEMENT-100-null-*action,N-ELEMENT-500-null-null");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    final AttributeDefinitions attributeDefinitions = dialectSetConfiguration.getAttributeDefinitions();
    final ElementDefinitions elementDefinitions = dialectSetConfiguration.getElementDefinitions();
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[N-ELEMENT-10-null-{th:src,data-th-src}, N-ELEMENT-15-{div}-{th:src,data-th-src}, N-ELEMENT-20-null-{th:src,data-th-src}]", attributeDefinitions.forHTMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-1-{th:form,th-form}-{action}, N-ELEMENT-10-null-{action}]", attributeDefinitions.forHTMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-20-{th:form,th-form}-null, N-ELEMENT-50-null-null]", elementDefinitions.forHTMLName("th", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forHTMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-50-null-null]", elementDefinitions.forHTMLName("p").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-100-null-{TH:src}, N-ELEMENT-150-{div}-{TH:src}, N-ELEMENT-200-null-{TH:src}]", attributeDefinitions.forXMLName("TH:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-10-{TH:form}-{action}, N-ELEMENT-100-null-{action}]", attributeDefinitions.forXMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-200-{TH:form}-null, N-ELEMENT-500-null-null]", elementDefinitions.forXMLName("TH", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("TH", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-500-null-null]", elementDefinitions.forXMLName("p").getAssociatedProcessors().toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) AttributeDefinitions(org.thymeleaf.engine.AttributeDefinitions) ElementDefinitions(org.thymeleaf.engine.ElementDefinitions) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 7 with DialectConfiguration

use of org.thymeleaf.DialectConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation08.

@Test
public void testProcessorComputation08() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "TH", "N-CDATA_SECTION-10-some,CD-4-other,N-COMMENT-10-some,C-4-other,N-DOC_TYPE-10-some,DT-4-other,N-PROCESSING_INSTRUCTION-10-some,PI-4-other,N-TEXT-10-some,T-4-other,N-XML_DECLARATION-10-some,XD-4-other", "N-CDATA_SECTION-100-some,CD-40-other,N-COMMENT-100-some,C-40-other,N-DOC_TYPE-100-some,DT-40-other,N-PROCESSING_INSTRUCTION-100-some,PI-40-other,N-TEXT-100-some,T-40-other,N-XML_DECLARATION-100-some,XD-40-other");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[CD-4-other, N-CDATA_SECTION-10-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[C-4-other, N-COMMENT-10-some]", dialectSetConfiguration.getCommentProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[DT-4-other, N-DOC_TYPE-10-some]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[PI-4-other, N-PROCESSING_INSTRUCTION-10-some]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[T-4-other, N-TEXT-10-some]", dialectSetConfiguration.getTextProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[XD-4-other, N-XML_DECLARATION-10-some]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[CD-40-other, N-CDATA_SECTION-100-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[C-40-other, N-COMMENT-100-some]", dialectSetConfiguration.getCommentProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[DT-40-other, N-DOC_TYPE-100-some]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[PI-40-other, N-PROCESSING_INSTRUCTION-100-some]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[T-40-other, N-TEXT-100-some]", dialectSetConfiguration.getTextProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[XD-40-other, N-XML_DECLARATION-100-some]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.XML).toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 8 with DialectConfiguration

use of org.thymeleaf.DialectConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation05.

@Test
public void testProcessorComputation05() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "TH", "N-ELEMENT-20-null-src, N-CDATA_SECTION-10-some,N-DOC_TYPE-20-other,E-20-null-text,E-10-null-text,N-TEXT-10-whoa!,E-15-*div-src,E-1-form-*action,N-ELEMENT-20-form-null,E-10-null-*action,E-50-null-null,N-CDATA_SECTION-5-someother,T-25-uye,T-10-eo", "N-TEXT-20-whoaX!,T-10-eoX");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    final AttributeDefinitions attributeDefinitions = dialectSetConfiguration.getAttributeDefinitions();
    final ElementDefinitions elementDefinitions = dialectSetConfiguration.getElementDefinitions();
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[E-15-{div}-{th:src,data-th-src}, N-ELEMENT-20-null-{th:src,data-th-src}]", attributeDefinitions.forHTMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-1-{th:form,th-form}-{action}, E-10-null-{action}]", attributeDefinitions.forHTMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-20-{th:form,th-form}-null, E-50-null-null]", elementDefinitions.forHTMLName("th", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forHTMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-50-null-null]", elementDefinitions.forHTMLName("p").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-CDATA_SECTION-5-someother, N-CDATA_SECTION-10-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[N-TEXT-10-whoa!, T-10-eo, T-25-uye]", dialectSetConfiguration.getTextProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[T-10-eoX, N-TEXT-20-whoaX!]", dialectSetConfiguration.getTextProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[N-DOC_TYPE-20-other]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCommentProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCommentProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.XML).toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) AttributeDefinitions(org.thymeleaf.engine.AttributeDefinitions) ElementDefinitions(org.thymeleaf.engine.ElementDefinitions) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 9 with DialectConfiguration

use of org.thymeleaf.DialectConfiguration in project thymeleaf-tests by thymeleaf.

the class TestTemplateEngineConfigurationBuilder method build.

public static IEngineConfiguration build() {
    final StandardDialect standardDialect = new StandardDialect();
    final DialectConfiguration standardDialectConfiguration = new DialectConfiguration(standardDialect);
    return new EngineConfiguration(Collections.singleton(standardDialectConfiguration), TextRepositories.createLimitedSizeCacheRepository());
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) EngineConfiguration(org.thymeleaf.EngineConfiguration) DialectConfiguration(org.thymeleaf.DialectConfiguration) StandardDialect(org.thymeleaf.standard.StandardDialect)

Aggregations

DialectConfiguration (org.thymeleaf.DialectConfiguration)9 Test (org.junit.Test)8 DialectSetConfiguration (org.thymeleaf.DialectSetConfiguration)8 IProcessorDialect (org.thymeleaf.dialect.IProcessorDialect)8 AttributeDefinitions (org.thymeleaf.engine.AttributeDefinitions)4 ElementDefinitions (org.thymeleaf.engine.ElementDefinitions)4 EngineConfiguration (org.thymeleaf.EngineConfiguration)1 IEngineConfiguration (org.thymeleaf.IEngineConfiguration)1 StandardDialect (org.thymeleaf.standard.StandardDialect)1