Class ExtensionCustomizer
- java.lang.Object
-
- io.pebbletemplates.pebble.extension.ExtensionCustomizer
-
- All Implemented Interfaces:
Extension
public abstract class ExtensionCustomizer extends java.lang.Object implements Extension
Base class that allows implementing a customizer to modify Pebbles build-in extensions. It is meant to provide a way to remove or replace functions, filters, tags, etc. to change the standard behaviour. Use-cases can be down-stripping available functionality for security reasons. Implementations of this class are meant to overwrite methods and access registered functionality before it is loaded into the PebbleEngine by calling super. The ExentsionCustomizer can be registred viaPebbleEngine.Builder.registerExtensionCustomizer(java.util.function.Function<io.pebbletemplates.pebble.extension.Extension, io.pebbletemplates.pebble.extension.ExtensionCustomizer>)
and is applied for every non-user-provided extension.
-
-
Constructor Summary
Constructors Constructor Description ExtensionCustomizer(Extension delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<AttributeResolver>
getAttributeResolver()
AttributeResolver will resolve instance attributesjava.util.List<BinaryOperator>
getBinaryOperators()
Use this method to provide custom binary operators.java.util.Map<java.lang.String,Filter>
getFilters()
Use this method to provide custom filters.java.util.Map<java.lang.String,Function>
getFunctions()
Use this method to provide custom functions.java.util.Map<java.lang.String,java.lang.Object>
getGlobalVariables()
Use this method to provide variables available to all templatesjava.util.List<NodeVisitorFactory>
getNodeVisitors()
Node visitors will travel the AST tree during the compilation phase.java.util.Map<java.lang.String,Test>
getTests()
Use this method to provide custom tests.java.util.List<TokenParser>
getTokenParsers()
Use this method to provide custom tags.java.util.List<UnaryOperator>
getUnaryOperators()
Use this method to provide custom unary operators.
-
-
-
Field Detail
-
delegate
private final Extension delegate
-
-
Constructor Detail
-
ExtensionCustomizer
public ExtensionCustomizer(Extension delegate)
-
-
Method Detail
-
getFilters
public java.util.Map<java.lang.String,Filter> getFilters()
Description copied from interface:Extension
Use this method to provide custom filters.- Specified by:
getFilters
in interfaceExtension
- Returns:
- A list of filters. It is okay to return null.
-
getTests
public java.util.Map<java.lang.String,Test> getTests()
Description copied from interface:Extension
Use this method to provide custom tests.
-
getFunctions
public java.util.Map<java.lang.String,Function> getFunctions()
Description copied from interface:Extension
Use this method to provide custom functions.- Specified by:
getFunctions
in interfaceExtension
- Returns:
- A list of functions. It is okay to return null.
-
getTokenParsers
public java.util.List<TokenParser> getTokenParsers()
Description copied from interface:Extension
Use this method to provide custom tags. A TokenParser is used to parse a stream of tokens into Nodes which are then responsible for compiling themselves into Java.- Specified by:
getTokenParsers
in interfaceExtension
- Returns:
- A list of TokenParsers. It is okay to return null.
-
getBinaryOperators
public java.util.List<BinaryOperator> getBinaryOperators()
Description copied from interface:Extension
Use this method to provide custom binary operators.- Specified by:
getBinaryOperators
in interfaceExtension
- Returns:
- A list of Operators. It is okay to return null;
-
getUnaryOperators
public java.util.List<UnaryOperator> getUnaryOperators()
Description copied from interface:Extension
Use this method to provide custom unary operators.- Specified by:
getUnaryOperators
in interfaceExtension
- Returns:
- A list of Operators. It is okay to return null;
-
getGlobalVariables
public java.util.Map<java.lang.String,java.lang.Object> getGlobalVariables()
Description copied from interface:Extension
Use this method to provide variables available to all templates- Specified by:
getGlobalVariables
in interfaceExtension
- Returns:
- Map of global variables available to all templates
-
getNodeVisitors
public java.util.List<NodeVisitorFactory> getNodeVisitors()
Description copied from interface:Extension
Node visitors will travel the AST tree during the compilation phase.- Specified by:
getNodeVisitors
in interfaceExtension
- Returns:
- a list of node visitors
-
getAttributeResolver
public java.util.List<AttributeResolver> getAttributeResolver()
Description copied from interface:Extension
AttributeResolver will resolve instance attributes- Specified by:
getAttributeResolver
in interfaceExtension
- Returns:
- a list of attribute resolver
-
-