Symfony2 API
Class

Symfony\Bundle\TwigBundle\TwigEngine

class TwigEngine extends TwigEngine implements EngineInterface

This engine renders Twig templates.

Methods

__construct(Twig_Environment $environment, TemplateNameParserInterface $parser, FileLocatorInterface $locator)

Constructor.

string render(mixed $name, array $parameters = array())

Renders a template.

stream(mixed $name, array $parameters = array())

Streams a template.

from TwigEngine
Boolean exists(mixed $name)

Returns true if the template exists.

from TwigEngine
Boolean supports(string $name)

Returns true if this class is able to render the given template.

from TwigEngine
setDefaultEscapingStrategy($strategy)

guessDefaultEscapingStrategy($filename)

Response renderResponse(string $view, array $parameters = array(), Response $response = null)

Renders a view and returns a Response.

Details

at line 37
public __construct(Twig_Environment $environment, TemplateNameParserInterface $parser, FileLocatorInterface $locator)

Constructor.

Parameters

Twig_Environment $environment A \Twig_Environment instance
TemplateNameParserInterface $parser A TemplateNameParserInterface instance
FileLocatorInterface $locator A FileLocatorInterface instance

at line 76
public string render(mixed $name, array $parameters = array())

Renders a template.

Parameters

mixed $name A template name
array $parameters An array of parameters to pass to the template

Return Value

string The evaluated template as a string

Exceptions

RuntimeException if the template cannot be rendered

in TwigEngine at line 64
public stream(mixed $name, array $parameters = array())

Streams a template.

The implementation should output the content directly to the client.

Parameters

mixed $name A template name or a TemplateReferenceInterface instance
array $parameters An array of parameters to pass to the template

Exceptions

RuntimeException if the template cannot be rendered
LogicException if the template cannot be streamed

in TwigEngine at line 76
public Boolean exists(mixed $name)

Returns true if the template exists.

Parameters

mixed $name A template name

Return Value

Boolean true if the template exists, false otherwise

in TwigEngine at line 94
public Boolean supports(string $name)

Returns true if this class is able to render the given template.

Parameters

string $name A template name

Return Value

Boolean True if this class supports the given resource, false otherwise

at line 44
public setDefaultEscapingStrategy($strategy)

Parameters

$strategy

at line 49
public guessDefaultEscapingStrategy($filename)

Parameters

$filename

at line 102
public Response renderResponse(string $view, array $parameters = array(), Response $response = null)

Renders a view and returns a Response.

Parameters

string $view The view name
array $parameters An array of parameters to pass to the view
Response $response A Response instance

Return Value

Response A Response instance