Test your Twig knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.
Question 1/5Score 0
What does the `~` operator do in a Twig expression, e.g. `{{ 'Hello, ' ~ name ~ '!' }}`?
Questions in this quiz
What does the `~` operator do in a Twig expression, e.g. `{{ 'Hello, ' ~ name ~ '!' }}`?
What is the basic syntax for outputting a variable's value in a Twig template?
What is Twig's "sandbox" mode used for?
How does Twig handle accessing a property or calling a method on a PHP object passed into a template, given the dot syntax like `{{ user.name }}`?
What is the purpose of `{% include %}` in Twig, and how does it differ from `{% extends %}`-based inheritance?
What is a reasonable justification for keeping business logic (like complex calculations, database queries, or validation) OUT of Twig templates, and instead computing that data in PHP controllers/services before passing it to the template?
What is a Twig "filter", and how is it applied to a value?
How does Twig typically handle template caching, and why does this matter for application performance?
How does Twig handle conditional logic (if/else) within a template?
What is the purpose of Twig's `{% set %}` tag?
How does Twig handle looping over a collection (like an array of items) in a template?
How do you deliberately output raw, unescaped HTML in a Twig template when auto-escaping would otherwise interfere (e.g. rendering trusted, pre-sanitized HTML content)?