Classes, interfaces and traits

TokenParserInterface

Interface implemented by token parsers.

« More »

AbstractTokenParser

Base class for all token parsers.

« More »

ApplyTokenParser

Applies filters on a section of a template.

{% apply upper %} This text becomes uppercase {% endapply %}

« More »

AutoEscapeTokenParser

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 %}

« More »

BlockTokenParser

Marks a section of a template as being reusable.

{% block head %}

{% block title %}{% endblock %} - My Webpage

{% endblock %}

« More »

DeprecatedTokenParser

Deprecates a section of a template.

{% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %} {% extends 'layout.html.twig' %}

« More »

DoTokenParser

Evaluates an expression, discarding the returned value.

« More »

EmbedTokenParser

Embeds a template.

{% include 'header.html' %} Body {% include 'footer.html' %}

« More »

ExtendsTokenParser

Extends a template by another one.

{% extends "base.html" %}

« More »

FilterTokenParser

Filters a section of a template by applying filters.

{% filter upper %} This text becomes uppercase {% endfilter %}

« More »

FlushTokenParser

Flushes the output to the client.

« More »

ForTokenParser

Loops over each item of a sequence.

    {% for user in users %}
  • {{ user.username|e }}
  • {% endfor %}
« More »

FromTokenParser

Imports macros.

{% from 'forms.html' import forms %}

« More »

IfTokenParser

Tests a condition.

{% if users %}

    {% for user in users %}
  • {{ user.username|e }}
  • {% endfor %}

{% endif %}

« More »

ImportTokenParser

Imports macros.

{% import 'forms.html' as forms %}

« More »

IncludeTokenParser

Includes a template.

{% include 'header.html' %} Body {% include 'footer.html' %}

« More »

MacroTokenParser

Defines a macro.

{% macro input(name, value, type, size) %}

{% endmacro %}

« More »

SandboxTokenParser

Marks a section of a template as untrusted code that must be evaluated in the sandbox mode.

{% sandbox %} {% include 'user.html' %} {% endsandbox %}

« More »

SetTokenParser

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 %}

« More »

SpacelessTokenParser

Remove whitespaces between HTML tags.

{% spaceless %}

foo

{% endspaceless %} {# output will be

foo
#}

« More »

UseTokenParser

Imports blocks defined in another template into the current template.

{% extends "base.html" %}

{% use "blocks.html" %}

{% block title %}{% endblock %} {% block content %}{% endblock %}

« More »

WithTokenParser

Creates a nested scope.

« More »