-
Notifications
You must be signed in to change notification settings - Fork 0
/
LPDialect.java
47 lines (40 loc) · 1.68 KB
/
LPDialect.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.ltpeacock.thymeleaf_dialect;
import java.util.HashSet;
import java.util.Set;
import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.StandardDialect;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;
import com.ltpeacock.thymeleaf_dialect.pagination.DefaultPageGenerator;
import com.ltpeacock.thymeleaf_dialect.pagination.PageGenerator;
import com.ltpeacock.thymeleaf_dialect.pagination.PaginationElementTagProcessor;
/**
* Lt. Peacock Dialect. Must be added to the {@link org.thymeleaf.TemplateEngine}
* to use tags with the {@code lp} prefix.
* @author LieutenantPeacock
*
*/
public class LPDialect extends AbstractProcessorDialect {
private static final String DIALECT_NAME = "Lt. Peacock Dialect";
private PageGenerator pageGenerator = new DefaultPageGenerator();
public LPDialect() {
super(DIALECT_NAME, "lp", StandardDialect.PROCESSOR_PRECEDENCE);
}
@Override
public Set<IProcessor> getProcessors(final String dialectPrefix) {
final Set<IProcessor> processors = new HashSet<>();
processors.add(new PaginationElementTagProcessor(dialectPrefix, pageGenerator));
processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
return processors;
}
/**
* Set the {@link PageGenerator} used by default for the {@code lp:pagination} tag.
* @param pageGenerator The PageGenerator to use when it is not specified
* as an attribute on the {@code lp:pagination} tag.
* The default is {@link DefaultPageGenerator}.
*/
public void setPageGenerator(PageGenerator pageGenerator) {
this.pageGenerator = pageGenerator;
}
}