05.
Including other Templates
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
4 Comments
Hello, please tell me
Challenge 2
Why in '_thirdTemplate.twig'
Set the value of a variable with set and use the default filter for the same variable?
In which case does the default filter work?
Hey Nina,
Tricky question, right? :) From the Twig docs:
> The default filter returns the passed default value if the value is undefined or empty, otherwise the value of the variable.
So it means if "number" variable does not exists at all or is empty, i.e. equal to an empty string, null, false - the value you passed to default filter will be used.
Cheers!
The syntax in the documentation is different from this. Has it changed? I had trouble getting this to work.
Hi Oliver!
Hmm, no it hasn't changed. You're probably referring to this syntax: {% include ... %} (http://twig.sensiolabs.org/.... That's an older syntax and the newer one - {{ include() }} is what you should use now. What error are you getting? Let's see if we can get it working :)
Cheers!
"Houston: no signs of life"
Start the conversation!