Search in sources :

Example 21 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method testProcessorIteration07.

@Test
public void testProcessorIteration07() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src,N-ELEMENT-2-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    tag.getAttributes().removeAttribute("th:src");
    tag.getAttributes().setAttribute("th:one", "somevalue");
    Assert.assertEquals("N-ELEMENT-2-null-{th:one,data-th-one}", iterator.next(tag).toString());
    Assert.assertNull(iterator.next(tag));
}
Also used : IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) Test(org.junit.Test)

Example 22 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method testProcessorIteration11.

@Test
public void testProcessorIteration11() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src,N-ELEMENT-2-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<div class='one'><a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    Assert.assertEquals("N-ELEMENT-5-null-{th:src,data-th-src}", iterator.next(tag).toString());
    tag.getAttributes().setAttribute("th:one", "somevalue");
    Assert.assertEquals("N-ELEMENT-2-null-{th:one,data-th-one}", iterator.next(tag).toString());
    tag.getAttributes().removeAttribute("th:src");
    Assert.assertNull(iterator.next(tag));
}
Also used : IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) Test(org.junit.Test)

Example 23 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method testProcessorIteration03.

@Test
public void testProcessorIteration03() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src,N-ELEMENT-7-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    Assert.assertEquals("N-ELEMENT-5-null-{th:src,data-th-src}", iterator.next(tag).toString());
    tag.getAttributes().setAttribute("th:one", "somevalue");
    Assert.assertEquals("N-ELEMENT-7-null-{th:one,data-th-one}", iterator.next(tag).toString());
    Assert.assertEquals("N-ELEMENT-10-null-{th:src,data-th-src}", iterator.next(tag).toString());
    Assert.assertNull(iterator.next(tag));
}
Also used : IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) Test(org.junit.Test)

Example 24 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method testProcessorIteration10.

@Test
public void testProcessorIteration10() {
    // This one checks that iteration also works OK for tags using a non-standard implementation
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src,N-ELEMENT-2-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    Assert.assertEquals("N-ELEMENT-5-null-{th:src,data-th-src}", iterator.next(tag).toString());
    tag.getAttributes().setAttribute("th:one", "somevalue");
    Assert.assertEquals("N-ELEMENT-2-null-{th:one,data-th-one}", iterator.next(tag).toString());
    tag.getAttributes().removeAttribute("th:src");
    Assert.assertNull(iterator.next(tag));
}
Also used : IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) Test(org.junit.Test)

Example 25 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method testProcessorIteration14.

@Test
public void testProcessorIteration14() {
    // This one checks that iteration also works OK for tags using a non-standard implementation
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-*a-src,N-ELEMENT-2-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<div class='one'><p th:src='uuuh'><a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    Assert.assertEquals("N-ELEMENT-5-{a}-{th:src,data-th-src}", iterator.next(tag).toString());
    tag.getAttributes().setAttribute("th:one", "somevalue");
    Assert.assertEquals("N-ELEMENT-2-null-{th:one,data-th-one}", iterator.next(tag).toString());
    tag.getAttributes().removeAttribute("th:src");
    Assert.assertNull(iterator.next(tag));
}
Also used : IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) Test(org.junit.Test)

Aggregations

IProcessorDialect (org.thymeleaf.dialect.IProcessorDialect)25 Test (org.junit.Test)22 IOpenElementTag (org.thymeleaf.model.IOpenElementTag)14 DialectConfiguration (org.thymeleaf.DialectConfiguration)8 DialectSetConfiguration (org.thymeleaf.DialectSetConfiguration)8 AttributeDefinitions (org.thymeleaf.engine.AttributeDefinitions)5 ElementDefinitions (org.thymeleaf.engine.ElementDefinitions)5 Map (java.util.Map)2 IDialect (org.thymeleaf.dialect.IDialect)2 IExecutionAttributeDialect (org.thymeleaf.dialect.IExecutionAttributeDialect)2 IExpressionObjectDialect (org.thymeleaf.dialect.IExpressionObjectDialect)2 IPostProcessorDialect (org.thymeleaf.dialect.IPostProcessorDialect)2 IPreProcessorDialect (org.thymeleaf.dialect.IPreProcessorDialect)2 IExpressionObjectFactory (org.thymeleaf.expression.IExpressionObjectFactory)2 IPostProcessor (org.thymeleaf.postprocessor.IPostProcessor)2 IPreProcessor (org.thymeleaf.preprocessor.IPreProcessor)2 IProcessor (org.thymeleaf.processor.IProcessor)2 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 LinkedHashMap (java.util.LinkedHashMap)1