Fork me on GitHub

PebbleTemplateImpl

In package com.mitchellbosecke.pebble.template

public class PebbleTemplateImpl extends Object implements PebbleTemplate

The actual implementation of a PebbleTemplate

Constructors

public PebbleTemplateImpl(PebbleEngine engine, RootNode root, String name)

Constructor

Parameters:
  • PebbleEngine engine

    The pebble engine used to construct this template

  • RootNode root

    The root not to evaluate

  • String name

    The name of the template

Methods

public void evaluate(Writer writer)
Parameters:
  • Writer writer
public void evaluate(Writer writer, Locale locale)
Parameters:
  • Writer writer
  • Locale locale
public void evaluate(Writer writer, Map<String, Object> map)
Parameters:
  • Writer writer
  • Map<String, Object> map
public void evaluate(Writer writer, Map<String, Object> map, Locale locale)
Parameters:
  • Writer writer
  • Map<String, Object> map
  • Locale locale
public void evaluateBlock(String blockName, Writer writer)
Parameters:
  • String blockName
  • Writer writer
public void evaluateBlock(String blockName, Writer writer, Locale locale)
Parameters:
  • String blockName
  • Writer writer
  • Locale locale
public void evaluateBlock(String blockName, Writer writer, Map<String, Object> map)
Parameters:
  • String blockName
  • Writer writer
  • Map<String, Object> map
public void evaluateBlock(String blockName, Writer writer, Map<String, Object> map, Locale locale)
Parameters:
  • String blockName
  • Writer writer
  • Map<String, Object> map
  • Locale locale
public void importTemplate(EvaluationContextImpl context, String name)

Imports a template.

Parameters:
public void importNamedTemplate(EvaluationContextImpl context, String name, String alias)

Imports a named template.

Parameters:
  • EvaluationContextImpl context

    The evaluation context

  • String name

    The template name

  • String alias

    The template alias

public void importNamedMacrosFromTemplate(String name, List<Pair<String, String>> namedMacros)

Imports named macros from specified template.

Parameters:
  • String name

    The template name

  • List<Pair<String, String>> namedMacros

    named macros

public PebbleTemplateImpl getNamedImportedTemplate(EvaluationContextImpl context, String alias)

Returns a named template.

Parameters:
public void includeTemplate(Writer writer, EvaluationContextImpl context, String name, Map<?, ?> additionalVariables)

Includes a template with {@code name} into this template.

Parameters:
  • Writer writer

    the writer to which the output should be written to.

  • EvaluationContextImpl context

    the context within which the template is rendered in.

  • String name

    the name of the template to include.

  • Map<?, ?> additionalVariables

    the map with additional variables provided with the include tag to add within the include tag.

public boolean hasMacro(String macroName)

Checks if a macro exists

Parameters:
  • String macroName

    The name of the macro

public boolean hasBlock(String blockName)

Checks if a block exists

Parameters:
  • String blockName

    The name of the block

public String resolveRelativePath(String relativePath)

This method resolves the given relative path based on this template file path.

Parameters:
  • String relativePath

    the path which should be resolved.

public void registerBlock(Block block)

Registers a block.

Parameters:
public void registerMacro(Macro macro)

Registers a macro

Parameters:
public void registerMacro(String alias, Macro macro)

Registers a macro with alias

Parameters:
  • String alias
  • Macro macro

    The macro

public void block(Writer writer, EvaluationContextImpl context, String blockName, boolean ignoreOverriden)

A typical block declaration will use this method which evaluates the block using the regular user-provided writer.

Parameters:
  • Writer writer

    The writer

  • EvaluationContextImpl context

    The evaluation context

  • String blockName

    The name of the block

  • boolean ignoreOverriden

    Whether or not to ignore overriden blocks

public SafeString macro(EvaluationContextImpl context, String macroName, ArgumentsNode args, boolean ignoreOverriden, int lineNumber)

Invokes a macro

Parameters:
  • EvaluationContextImpl context

    The evaluation context

  • String macroName

    The name of the macro

  • ArgumentsNode args

    The arguments

  • boolean ignoreOverriden

    Whether or not to ignore macro definitions in child template

  • int lineNumber
public void setParent(EvaluationContextImpl context, String parentName)
Parameters:
public String getName()

Returns the template name

Parameters:
  • No parameters