public class PebbleTemplateImpl extends Object implements PebbleTemplate
| Constructor and Description |
|---|
PebbleTemplateImpl(PebbleEngine engine,
RootNode root,
String name)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
block(Writer writer,
EvaluationContext context,
String blockName,
boolean ignoreOverriden)
A typical block declaration will use this method which evaluates the
block using the regular user-provided writer.
|
void |
evaluate(Writer writer)
Evaluate the template without any provided variables.
|
void |
evaluate(Writer writer,
Locale locale)
Evaluate the template with a particular locale but without any provided variables.
|
void |
evaluate(Writer writer,
Map<String,Object> map)
Evaluate the template with a set of variables and the default locale provided by the
PebbleEngine |
void |
evaluate(Writer writer,
Map<String,Object> map,
Locale locale)
Evaluate the template with a particular locale and a set of variables.
|
void |
evaluateBlock(String blockName,
Writer writer)
Evaluate the template but only render the contents of a specific block.
|
void |
evaluateBlock(String blockName,
Writer writer,
Locale locale)
Evaluate the template but only render the contents of a specific block.
|
void |
evaluateBlock(String blockName,
Writer writer,
Map<String,Object> map)
Evaluate the template but only render the contents of a specific block.
|
void |
evaluateBlock(String blockName,
Writer writer,
Map<String,Object> map,
Locale locale)
Evaluate the template but only render the contents of a specific block.
|
String |
getName()
Returns the template name
|
PebbleTemplateImpl |
getNamedImportedTemplate(EvaluationContext context,
String alias)
Returns a named template.
|
boolean |
hasBlock(String blockName)
Checks if a block exists
|
boolean |
hasMacro(String macroName)
Checks if a macro exists
|
void |
importNamedMacrosFromTemplate(EvaluationContext context,
String name,
List<Pair<String,String>> namedMacros)
Imports named macros from specified template.
|
void |
importNamedTemplate(EvaluationContext context,
String name,
String alias)
Imports a named template.
|
void |
importTemplate(EvaluationContext context,
String name)
Imports a template.
|
void |
includeTemplate(Writer writer,
EvaluationContext context,
String name,
Map<?,?> additionalVariables)
Includes a template with
name into this template. |
SafeString |
macro(EvaluationContext context,
String macroName,
ArgumentsNode args,
boolean ignoreOverriden,
int lineNumber)
Invokes a macro
|
void |
registerBlock(Block block)
Registers a block.
|
void |
registerMacro(Macro macro)
Registers a macro
|
void |
registerMacro(String alias,
Macro macro)
Registers a macro with alias
|
String |
resolveRelativePath(String relativePath)
This method resolves the given relative path based on this template file
path.
|
void |
setParent(EvaluationContext context,
String parentName) |
public PebbleTemplateImpl(PebbleEngine engine, RootNode root, String name)
engine - The pebble engine used to construct this templateroot - The root not to evaluatename - The name of the templatepublic void evaluate(Writer writer) throws IOException
PebbleTemplatePebbleEngine.evaluate in interface PebbleTemplatewriter - The results of the evaluation are written to this writer.IOException - An IO exception during the evaluationpublic void evaluate(Writer writer, Locale locale) throws IOException
PebbleTemplateevaluate in interface PebbleTemplatewriter - The results of the evaluation are written to this writer.locale - The locale used during the evaluation of the template.IOException - An IO exception during the evaluationpublic void evaluate(Writer writer, Map<String,Object> map) throws IOException
PebbleTemplatePebbleEngineevaluate in interface PebbleTemplatewriter - The results of the evaluation are written to this writer.map - The variables used during the evaluation of the template.IOException - An IO exception during the evaluationpublic void evaluate(Writer writer, Map<String,Object> map, Locale locale) throws IOException
PebbleTemplateevaluate in interface PebbleTemplatewriter - The results of the evaluation are written to this writer.map - The variables used during the evaluation of the template.locale - The locale used during the evaluation of the template.IOException - An IO exception during the evaluationpublic void evaluateBlock(String blockName, Writer writer) throws IOException
PebbleTemplateevaluateBlock in interface PebbleTemplateblockName - The name of the template block to return.writer - The results of the evaluation are written to this writer.IOException - An IO exception during the evaluationpublic void evaluateBlock(String blockName, Writer writer, Locale locale) throws IOException
PebbleTemplateevaluateBlock in interface PebbleTemplateblockName - The name of the template block to return.writer - The results of the evaluation are written to this writer.locale - The locale used during the evaluation of the template.IOException - An IO exception during the evaluationpublic void evaluateBlock(String blockName, Writer writer, Map<String,Object> map) throws IOException
PebbleTemplateevaluateBlock in interface PebbleTemplateblockName - The name of the template block to return.writer - The results of the evaluation are written to this writer.map - The variables used during the evaluation of the template.IOException - An IO exception during the evaluationpublic void evaluateBlock(String blockName, Writer writer, Map<String,Object> map, Locale locale) throws IOException
PebbleTemplateevaluateBlock in interface PebbleTemplateblockName - The name of the template block to return.writer - The results of the evaluation are written to this writer.map - The variables used during the evaluation of the template.locale - The locale used during the evaluation of the template.IOException - An IO exception during the evaluationpublic void importTemplate(EvaluationContext context, String name)
context - The evaluation contextname - The template namepublic void importNamedTemplate(EvaluationContext context, String name, String alias)
context - The evaluation contextname - The template namealias - The template aliaspublic void importNamedMacrosFromTemplate(EvaluationContext context, String name, List<Pair<String,String>> namedMacros)
context - The evaluation contextname - The template namenamedMacros - named macrosPebbleExceptionpublic PebbleTemplateImpl getNamedImportedTemplate(EvaluationContext context, String alias)
context - The evaluation contextalias - The template aliaspublic void includeTemplate(Writer writer, EvaluationContext context, String name, Map<?,?> additionalVariables) throws IOException
name into this template.writer - the writer to which the output should be written to.context - the context within which the template is rendered in.name - the name of the template to include.additionalVariables - the map with additional variables provided with the include
tag to add within the include tag.IOException - Any error during the loading of the templatepublic boolean hasMacro(String macroName)
macroName - The name of the macropublic boolean hasBlock(String blockName)
blockName - The name of the blockpublic String resolveRelativePath(String relativePath)
relativePath - the path which should be resolved.public void registerBlock(Block block)
block - The blockpublic void registerMacro(Macro macro)
macro - The macropublic void registerMacro(String alias, Macro macro)
macro - The macroPebbleException - Throws exception if macro already exists with the same namepublic void block(Writer writer, EvaluationContext context, String blockName, boolean ignoreOverriden) throws IOException
blockName - The name of the blockcontext - The evaluation contextignoreOverriden - Whether or not to ignore overriden blockswriter - The writerIOException - Thrown from the writer objectpublic SafeString macro(EvaluationContext context, String macroName, ArgumentsNode args, boolean ignoreOverriden, int lineNumber)
context - The evaluation contextmacroName - The name of the macroargs - The argumentsignoreOverriden - Whether or not to ignore macro definitions in child templatepublic void setParent(EvaluationContext context, String parentName)
public String getName()
getName in interface PebbleTemplateCopyright © 2018. All rights reserved.