Symfony

Twig & Templates

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

20 питань зі співбесід·
Junior
1

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

Відповідь

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?

Відповідь

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?

Відповідь

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 питань зі співбесід

Опануй Symfony для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно