Symfony

Twig & Templates

Twig syntax, variables, filters, extends, include, blocks, forms rendering, assets

20 preguntas de entrevista·
Junior
1

Which syntax is used to display a variable in a Twig template?

Respuesta

The {{ }} (double curly braces) syntax is used to display a variable's content in Twig. This syntax automatically performs HTML escaping to prevent XSS attacks. For control structures, use {% %}, and for comments use {# #}.

2

How to write a comment in a Twig template?

Respuesta

Twig comments use the {# #} syntax. These comments are not rendered in the final HTML output, unlike standard HTML comments. This allows adding developer notes without exposing information to users.

3

What is the purpose of the {% extends %} tag in Twig?

Respuesta

The extends tag enables template inheritance by defining a parent template. The child template inherits the entire parent structure and can override defined blocks. This promotes reusability and maintains a consistent structure across the site.

4

Which Twig function generates the URL of an asset file (CSS, JS, image)?

5

How to include another Twig template inside a template?

+17 preguntas de entrevista

Domina Symfony para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis