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/5Score 0

What is a reasonable strategy for organizing multiple related custom filters/functions within a project -- should they all live in one single giant extension class, or be split into several smaller extension classes?

Questions in this quiz
  1. What is a reasonable strategy for organizing multiple related custom filters/functions within a project -- should they all live in one single giant extension class, or be split into several smaller extension classes?
  2. 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?
  3. How does registering a custom Twig extension in a Symfony application typically happen (in terms of dependency injection/service registration)?
  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. What is the relationship between Twig's own bundled/built-in extensions (like the "Core" extension providing `if`/`for`/`upper`/`lower`, etc.) and the concept of a user-defined custom extension?
  6. How do you create a custom Twig filter within an extension, and what does it let a template do?
  7. 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 %}`?
  8. What is the purpose of `getGlobals()` in a Twig extension, as distinct from `getFilters()`/`getFunctions()`?
  9. What is a custom Twig "tag" (registered via a `TokenParser`), and why is it generally considered more complex to implement than a custom filter or function?
  10. What is the purpose of the `TwigFilter`/`TwigFunction`/`TwigTest` classes themselves (as opposed to just returning plain arrays or callables directly)?
  11. 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?
  12. What is the significance of a Twig filter/function extension being able to accept OPTIONS (like `needs_environment` or `needs_context`) when registered?
Gaps to close?
Read the curated Twig Extensions notes — core concepts, patterns, interview prep.
Twig Extensions notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web