Search in sources :

Example 1 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration02.

@Test
public void testProcessorIteration02() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src,N-ELEMENT-15-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-10-null-{th:src,data-th-src}", iterator.next(tag).toString());
    Assert.assertEquals("N-ELEMENT-15-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 2 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration04.

@Test
public void testProcessorIteration04() {
    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());
    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 3 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration08.

@Test
public void testProcessorIteration08() {
    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");
    tag.getAttributes().removeAttribute("data-th-src");
    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 4 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration09.

@Test
public void testProcessorIteration09() {
    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 5 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration01.

@Test
public void testProcessorIteration01() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src");
    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(handler.tag).toString());
    Assert.assertEquals("N-ELEMENT-10-null-{th:src,data-th-src}", iterator.next(handler.tag).toString());
    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