ch.mfrey.thymeleaf.extras.cache.CacheDialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thymeleaf-cache-dialect Show documentation
Show all versions of thymeleaf-cache-dialect Show documentation
A dialect for Thymeleaf that allows you to do partial page caching.
Some parts of our webpage will never change during the lifetime of the application or a usersession, but the part should still be dynamic in the beginning.
Working with Thymeleaf 3.0.0+ (3.0.0.RELEASE and its dependencies included)
package ch.mfrey.thymeleaf.extras.cache;
import java.util.HashSet;
import java.util.Set;
import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;
import org.thymeleaf.standard.processor.StandardXmlNsTagProcessor;
import org.thymeleaf.templatemode.TemplateMode;
public class CacheDialect extends AbstractProcessorDialect {
public static final String DIALECT_NAMESPACE = "http://www.thymeleaf.org/extras/cache";
public static final String DIALECT_PREFIX = "cache";
public CacheDialect() {
super(DIALECT_NAMESPACE, DIALECT_PREFIX, 0);
}
/**
* {@inheritDoc}
*/
public Set getProcessors(String dialectPrefix) {
HashSet processors = new HashSet();
processors.add(new StandardXmlNsTagProcessor(TemplateMode.HTML, dialectPrefix));
processors.add(new CacheProcessor(TemplateMode.HTML, dialectPrefix));
processors.add(new CacheAddProcessor(TemplateMode.HTML, dialectPrefix));
processors.add(new CacheEvictProcessor(TemplateMode.HTML, dialectPrefix));
return processors;
}
}