Package io.pebbletemplates.pebble
Class PebbleEngine
- java.lang.Object
-
- io.pebbletemplates.pebble.PebbleEngine
-
public class PebbleEngine extends java.lang.Object
The main class used for compiling templates. The PebbleEngine is responsible for delegating responsibility to the lexer, parser, compiler, and template cache.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PebbleEngine.Builder
A builder to configure and construct an instance of a PebbleEngine.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Locale
defaultLocale
private EvaluationOptions
evaluationOptions
private java.util.concurrent.ExecutorService
executorService
private ExtensionRegistry
extensionRegistry
private Loader<?>
loader
private org.slf4j.Logger
logger
private int
maxRenderedSize
private ParserOptions
parserOptions
private boolean
strictVariables
private Syntax
syntax
private PebbleCache<CacheKey,java.lang.Object>
tagCache
private PebbleCache<java.lang.Object,PebbleTemplate>
templateCache
-
Constructor Summary
Constructors Modifier Constructor Description private
PebbleEngine(Loader<?> loader, Syntax syntax, boolean strictVariables, java.util.Locale defaultLocale, int maxRenderedSize, PebbleCache<CacheKey,java.lang.Object> tagCache, PebbleCache<java.lang.Object,PebbleTemplate> templateCache, java.util.concurrent.ExecutorService executorService, ExtensionRegistry extensionRegistry, ParserOptions parserOptions, EvaluationOptions evaluationOptions)
Constructor for the Pebble Engine given an instantiated Loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Locale
getDefaultLocale()
Returns the default localeEvaluationOptions
getEvaluationOptions()
java.util.concurrent.ExecutorService
getExecutorService()
Returns the executor serviceExtensionRegistry
getExtensionRegistry()
Returns the extension registry.PebbleTemplate
getLiteralTemplate(java.lang.String templateName)
Loads, parses, and compiles a template using a StringLoader into an instance of PebbleTemplate and returns this instance.Loader<?>
getLoader()
Returns the loaderint
getMaxRenderedSize()
Returns the max rendered size.private PebbleTemplate
getPebbleTemplate(java.lang.String templateName, Loader loader, java.lang.Object cacheKey)
Syntax
getSyntax()
Returns the syntax which is used by this PebbleEngine.PebbleCache<CacheKey,java.lang.Object>
getTagCache()
Returns the tag cachePebbleTemplate
getTemplate(java.lang.String templateName)
Loads, parses, and compiles a template into an instance of PebbleTemplate and returns this instance.private PebbleTemplate
getTemplate(java.lang.String templateName, Loader loader)
PebbleCache<java.lang.Object,PebbleTemplate>
getTemplateCache()
Returns the template cacheboolean
isStrictVariables()
Returns the strict variables setting
-
-
-
Field Detail
-
logger
private final org.slf4j.Logger logger
-
loader
private final Loader<?> loader
-
syntax
private final Syntax syntax
-
strictVariables
private final boolean strictVariables
-
defaultLocale
private final java.util.Locale defaultLocale
-
maxRenderedSize
private final int maxRenderedSize
-
tagCache
private final PebbleCache<CacheKey,java.lang.Object> tagCache
-
executorService
private final java.util.concurrent.ExecutorService executorService
-
templateCache
private final PebbleCache<java.lang.Object,PebbleTemplate> templateCache
-
extensionRegistry
private final ExtensionRegistry extensionRegistry
-
parserOptions
private final ParserOptions parserOptions
-
evaluationOptions
private final EvaluationOptions evaluationOptions
-
-
Constructor Detail
-
PebbleEngine
private PebbleEngine(Loader<?> loader, Syntax syntax, boolean strictVariables, java.util.Locale defaultLocale, int maxRenderedSize, PebbleCache<CacheKey,java.lang.Object> tagCache, PebbleCache<java.lang.Object,PebbleTemplate> templateCache, java.util.concurrent.ExecutorService executorService, ExtensionRegistry extensionRegistry, ParserOptions parserOptions, EvaluationOptions evaluationOptions)
Constructor for the Pebble Engine given an instantiated Loader. This method does only load those userProvidedExtensions listed here.- Parameters:
loader
- The template loader for this enginesyntax
- the syntax to use for parsing the templates.
-
-
Method Detail
-
getTemplate
public PebbleTemplate getTemplate(java.lang.String templateName)
Loads, parses, and compiles a template into an instance of PebbleTemplate and returns this instance.- Parameters:
templateName
- The name of the template- Returns:
- PebbleTemplate The compiled version of the template
-
getLiteralTemplate
public PebbleTemplate getLiteralTemplate(java.lang.String templateName)
Loads, parses, and compiles a template using a StringLoader into an instance of PebbleTemplate and returns this instance.- Parameters:
templateName
- The name of the template- Returns:
- PebbleTemplate The compiled version of the template
-
getTemplate
private PebbleTemplate getTemplate(java.lang.String templateName, Loader loader)
-
getPebbleTemplate
private PebbleTemplate getPebbleTemplate(java.lang.String templateName, Loader loader, java.lang.Object cacheKey)
-
getLoader
public Loader<?> getLoader()
Returns the loader- Returns:
- The loader
-
getTemplateCache
public PebbleCache<java.lang.Object,PebbleTemplate> getTemplateCache()
Returns the template cache- Returns:
- The template cache
-
isStrictVariables
public boolean isStrictVariables()
Returns the strict variables setting- Returns:
- The strict variables setting
-
getDefaultLocale
public java.util.Locale getDefaultLocale()
Returns the default locale- Returns:
- The default locale
-
getMaxRenderedSize
public int getMaxRenderedSize()
Returns the max rendered size.- Returns:
- The max rendered size.
-
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService()
Returns the executor service- Returns:
- The executor service
-
getSyntax
public Syntax getSyntax()
Returns the syntax which is used by this PebbleEngine.- Returns:
- the syntax used by the PebbleEngine.
-
getExtensionRegistry
public ExtensionRegistry getExtensionRegistry()
Returns the extension registry.- Returns:
- The extension registry
-
getTagCache
public PebbleCache<CacheKey,java.lang.Object> getTagCache()
Returns the tag cache- Returns:
- The tag cache
-
getEvaluationOptions
public EvaluationOptions getEvaluationOptions()
-
-