All quizzes
Free quiz · 20 questions in the bank

Twig Extensions quiz

Test your Twig Extensions knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

What is a reasonable justification for keeping custom Twig extension code (filters/functions) focused purely on PRESENTATION-related transformations, rather than embedding genuine business logic (like a discount calculation) inside an extension?

In this round
  1. What is a reasonable justification for keeping custom Twig extension code (filters/functions) focused purely on PRESENTATION-related transformations, rather than embedding genuine business logic (like a discount calculation) inside an extension?
  2. How does registering a custom Twig extension in a Symfony application typically happen (in terms of dependency injection/service registration)?
  3. What is a custom Twig "test" (registered via `getTests()` in an extension), and how is it used in a template, e.g. `{% if product is expensive %}`?
  4. What happens if two different registered Twig extensions both attempt to register a filter with the SAME name (e.g. both defining a filter called "format")?
  5. How do you create a custom Twig filter within an extension, and what does it let a template do?
  6. What is the significance of a Twig filter/function extension being able to accept OPTIONS (like `needs_environment` or `needs_context`) when registered?
  7. Why might overusing custom Twig extensions to add many highly-specific, narrowly-applicable filters/functions eventually become a maintenance concern for a project?
  8. What is the purpose of the `TwigFilter`/`TwigFunction`/`TwigTest` classes themselves (as opposed to just returning plain arrays or callables directly)?
  9. What does it mean that a Twig filter/function can be registered with the `is_safe` option (e.g. `new TwigFilter('markdown', [$this, 'renderMarkdown'], ['is_safe' => ['html']])`)?
  10. What is the purpose of `getGlobals()` in a Twig extension, as distinct from `getFilters()`/`getFunctions()`?
  11. What is the difference between registering a custom Twig "function" versus a custom "filter" within an extension, in terms of how they're called from a template?
  12. What is a "Twig node visitor" (an advanced extension feature registered via `getNodeVisitors()`), and how does it differ from a simple filter/function?
Gaps to close?
Read the curated Twig Extensions notes — core concepts, patterns, interview prep.
Twig Extensions notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web