WIP Idea to avoid repeating ourselves so much in templates #2025
This branch shows the simplified base_helper.tmpl in bootstrap3
You only have to do the silly redefinition-calling-parent for functions that are called from within that same file.
Looks like I have run into something where mako is just too different from jinja to make jinjify work :-(
There seems to be no way to make this work in Jinja2, because blocks are not callable!
So, this means we should use macros instead of blocks, which means defs instead of blocks in Mako. May still be worth doing...
What do you mean "def-heavy"? Would this be more useful if there were more defs in the base theme? I'm kind of planning of making more defs in the base theme, if that makes a difference. In a few weeks time, most likely. Testing out some stuff with my own site and thought I'd clean it up and introduce
@Aeyoun for files that are a bunch of defs this is very useful (see the change in nikola/data/themes/bootstrap3/templates/base_helper.tmpl), basically, only have to keep the functions you change, the rest will be "inherited".
For blocks, that doesn't work, so this technique doesn't help avoid repetition (fairly: it works in Mako, doesn't work in Jinja).
So, the more templates we have that are collections of defs, the more this avoids stupid repetition.