Theming

If Statements with Twig Tests

Last updated
Categories
Sprout Video

In our last tutorial we have things set up to include a new template, but we are currently getting an error, due to not passing the correct variable. In this tutorial we'll see how to fix this problem by adding a "defined" test to our code, which will check to see if the variable is defined in the _banner.twig template, and default to "lightblue" if it is not.

Additional resources

Twig defined test documentation