
Twig & Templates
Twig syntax, variables, filters, extends, include, blocks, forms rendering, assets
1Which syntax is used to display a variable in a Twig template?
Which syntax is used to display a variable in a Twig template?
Answer
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 {# #}.
2How to write a comment in a Twig template?
How to write a comment in a Twig template?
Answer
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.
3What is the purpose of the {% extends %} tag in Twig?
What is the purpose of the {% extends %} tag in Twig?
Answer
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.
Which Twig function generates the URL of an asset file (CSS, JS, image)?
How to include another Twig template inside a template?
+17 interview questions
Other Symfony interview topics
Modern PHP (8.1+)
Symfony Basics
Routing & Controllers
Doctrine ORM Basics
Symfony Forms
Data Validation
Dependency Injection & Services
Security & Authentication
Doctrine Advanced
API Platform
Serializer Component
Events & Event Subscribers
Console & Commands
Messenger Component
HTTP Client
Cache & Performance
Workflow Component
Testing Symfony
Mailer Component
Translations & i18n
EasyAdmin Bundle
Symfony Architecture
Performance & Optimization
Security Advanced
Custom Bundles
Microservices with Symfony
Real-time & WebSockets
Deployment & DevOps
Master Symfony for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free