Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
add blocks #164
Migrated issue, originally created by Michael Bayer (@zzzeek)
pretty intuitive, the block is essentially just like a def except it invokes immediately.
is equivalent to:
where "_anon_1" is generated, except that there is no "_anon_1" def which is "exported". Blocks are more private than top-level defs.
The block can of course have a name, which is generally for when inheritance is used. The rules then change a bit:
is equivalent to, minus the top level def export:
i.e. named blocks exec off of self and only if the parent doesn't have such a block. That way, the bottommost template in an inheritance chain determines when a block of a certain name occurs, giving us the jinja2 system of inheritance: