Home

twig

Twig is a modern templating language for PHP. It was created by Fabien Potencier and released in 2009, and it is developed as part of the Symfony ecosystem. Twig emphasizes readability, security, and performance, compiling templates to optimized PHP code and using caching to speed up rendering while keeping presentation and logic separate.

Twig syntax uses three delimiters: {{ expression }} for output, {% statement %} for control structures, and {# comments #} for notes

A key design principle of Twig is security. It provides automatic escaping by default for HTML output

Twig is released as open-source software under a BSD-style license and is maintained independently of PHP itself.

within
templates.
The
engine
supports
template
inheritance
through
extends
and
blocks,
as
well
as
includes
and
embeds
for
composing
templates.
It
offers
a
rich
set
of
features,
including
filters,
tests,
functions,
and
macros,
and
it
allows
developers
to
create
custom
extensions
to
add
new
capabilities.
to
help
prevent
cross-site
scripting,
with
configurable
options
to
disable
escaping
when
needed.
The
templating
language
is
extensible,
enabling
the
creation
of
custom
filters,
tests,
and
functions,
and
it
supports
sandbox
mode
for
restricted
execution
in
untrusted
environments.
It
is
widely
used
across
PHP
frameworks
and
projects,
most
notably
as
the
default
templating
engine
in
Symfony,
and
is
also
employed
in
other
systems
such
as
Drupal
8
and
later.
It
can
be
used
as
a
standalone
library
or
integrated
into
larger
web
applications
through
framework
adapters.