Template

Implements\Twig_TemplateInterface

Default base class for compiled templates.

This class is an implementation detail of how template compilation currently works, which might change. It should never be used directly. Use $twig->load() instead, which returns an instance of \Twig\TemplateWrapper.

author

Fabien Potencier fabien@symfony.com

internal
package

Default

Methods

__construct

__construct(\Twig\Environment $env)

Arguments

$env

\Twig\Environment

display

display(array $context,array $blocks = array())

Arguments

$context

array

$blocks

array

Displays a block.

displayBlock(string $name,array $context,array $blocks = array(),boolean $useBlocks = true)

This method is for internal use only and should never be called directly.

Arguments

$name

string

The block name to display

$context

array

The context

$blocks

array

The current set of blocks

$useBlocks

boolean

Whether to use the current set of blocks

Displays a parent block.

displayParentBlock(string $name,array $context,array $blocks = array())

This method is for internal use only and should never be called directly.

Arguments

$name

string

The block name to display from the parent

$context

array

The context

$blocks

array

The current set of blocks

displayWithErrorHandling

displayWithErrorHandling(array $context,array $blocks = array())

Arguments

$context

array

$blocks

array

Auto-generated method to display the template with the given context.

doDisplay(array $context,array $blocks = array())
abstract

Arguments

$context

array

An array of parameters to pass to the template

$blocks

array

An array of blocks to pass to the template

doGetParent

doGetParent(array $context)

Arguments

$context

array

Returns all block names in the current context of the template.

getBlockNames(array $context = null,array $blocks = array()): array

This method checks blocks defined in the current template or defined in "used" traits or defined in parent templates.

Arguments

$context

array

The context

$blocks

array

The current set of blocks

Response

array

An array of block names

Returns all blocks.

getBlocks(): array

This method is for internal use only and should never be called directly.

Response

array

An array of blocks

Returns debug information about the template.

getDebugInfo(): array

Response

array

Debug information

getEnvironment

getEnvironment()
deprecated

since 1.20 (to be removed in 2.0)

Returns the template source code.

getSource(): string
deprecated

since 1.27 (to be removed in 2.0). Use getSourceContext() instead

Response

string

The template source code

Returns information about the original template source code.

getSourceContext(): \Twig\Source

Response

\Twig\Source

Returns the template name.

getTemplateName(): string
abstract

Response

string

The template name

Returns whether a block exists or not in the current context of the template.

hasBlock(string $name,array $context = null,array $blocks = array()): boolean

This method checks blocks defined in the current template or defined in "used" traits or defined in parent templates.

Arguments

$name

string

The block name

$context

array

The context

$blocks

array

The current set of blocks

Response

boolean

true if the block exists, false otherwise

isTraitable

isTraitable()

loadTemplate

loadTemplate( $template, $templateName = null, $line = null, $index = null): \Twig\Template|\Twig\TemplateWrapper

Arguments

$template

$templateName

$line

$index

Response

\Twig\Template|\Twig\TemplateWrapper

render

render(array $context)

Arguments

$context

array

Renders a block.

renderBlock(string $name,array $context,array $blocks = array(),boolean $useBlocks = true): string

This method is for internal use only and should never be called directly.

Arguments

$name

string

The block name to render

$context

array

The context

$blocks

array

The current set of blocks

$useBlocks

boolean

Whether to use the current set of blocks

Response

string

The rendered block

Renders a parent block.

renderParentBlock(string $name,array $context,array $blocks = array()): string

This method is for internal use only and should never be called directly.

Arguments

$name

string

The block name to render from the parent

$context

array

The context

$blocks

array

The current set of blocks

Response

string

The rendered block

Properties

parent

parent :

Type(s)

parents

parents :

Type(s)

env

env :

Type(s)

blocks

blocks :

Type(s)

traits

traits :

Type(s)

sandbox

sandbox :

Type(s)