Default autoescaping strategy based on file names.
This strategy sets the HTML as the default autoescaping strategy, but changes it based on the template name.
Note that there is no runtime performance impact as the default autoescaping strategy is set at compilation time.
A node traverser.
It visits all nodes and their children and calls the given visitor for each.
Enables usage of the deprecated Twig\Extension\AbstractExtension::getGlobals() method.
Explicitly implement this interface if you really need to implement the deprecated getGlobals() method in your extensions.
Enables usage of the deprecated Twig\Extension\AbstractExtension::initRuntime() method.
Explicitly implement this interface if you really need to implement the deprecated initRuntime() method in your extensions.
Twig base exception.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when an error occurs during template loading.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when an error occurs at runtime.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
\Exception thrown when a syntax error occurs during lexing or parsing of a template.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Represents an autoescape node.
The value is the escaping strategy (can be html, js, ...)
The true value is equivalent to html.
If autoescaping is disabled, then the value is false.
Checks if casting an expression to __toString() is allowed by the sandbox.
For instance, when there is a simple Print statement, like {{ article }}, and if the sandbox is enabled, we need to check that the __toString() method is allowed if 'article' is an object. The same goes for {{ article|upper }} or {{ random(article) }}
Adds a check for the __toString() method when the variable is an object and the sandbox is activated.
When there is a simple Print statement, like {{ article }}, and if the sandbox is enabled, we need to check that the __toString() method is allowed if 'article' is an object.
Not used anymore, to be deprecated in 2.x and removed in 3.0
Checks if a variable is the exact same value as a constant.
{% if post.status is constant('Post::PUBLISHED') %} the status attribute is exactly the same as Post::PUBLISHED {% endif %}
Exception thrown when a security error occurs at runtime.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when a not allowed filter is used in a template.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when a not allowed function is used in a template.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when a not allowed class method is used in a template.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when a not allowed class property is used in a template.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Exception thrown when a not allowed tag is used in a template.
This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).
To help debugging template issues, this class tracks the original template name and line where the error occurred.
Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.
Loads a template from an array.
When using this loader with a cache mechanism, you should know that a new cache key is generated each time a template content "changes" (the cache key being the source code of the template). If you don't want to see your cache grows out of control, you need to take care of clearing the old cache file by yourself.
This loader should only be used for unit testing.
Creates runtime implementations for Twig elements (filters/functions/tests).
Used to make node visitors compatible with Twig 1.x and 2.x.
To be removed in Twig 3.1.
Used to make node visitors compatible with Twig 1.x and 2.x.
To be removed in Twig 3.1.
Applies filters on a section of a template.
{% apply upper %} This text becomes uppercase {% endapply %}
Marks a section of a template to be escaped or not.
{% autoescape true %} Everything will be automatically escaped in this block {% endautoescape %}
{% autoescape false %} Everything will be outputed as is in this block {% endautoescape %}
{% autoescape true js %} Everything will be automatically escaped in this block using the js escaping strategy {% endautoescape %}
Marks a section of a template as being reusable.
{% block head %}
{% endblock %}
Deprecates a section of a template.
{% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %} {% extends 'layout.html.twig' %}
Embeds a template.
{% include 'header.html' %} Body {% include 'footer.html' %}
Filters a section of a template by applying filters.
{% filter upper %} This text becomes uppercase {% endfilter %}
Loops over each item of a sequence.
Tests a condition.
{% if users %}
{% endif %}
Includes a template.
{% include 'header.html' %} Body {% include 'footer.html' %}
Defines a macro.
{% macro input(name, value, type, size) %}
{% endmacro %}
Marks a section of a template as untrusted code that must be evaluated in the sandbox mode.
{% sandbox %} {% include 'user.html' %} {% endsandbox %}
Defines a variable.
{% set foo = 'foo' %} {% set foo = [1, 2] %} {% set foo = {'foo': 'bar'} %} {% set foo = 'foo' ~ 'bar' %} {% set foo, bar = 'foo', 'bar' %} {% set foo %}Some content{% endset %}
Remove whitespaces between HTML tags.
{% spaceless %}
{% endspaceless %} {# output will be