makoのinheritsはoverrideなので上書き
akoのinheritsはoverrideなので上書き。継承元のブロックと同名の名前付きブロックを呼んだとき、継承元のブロックの中身はレンダリングされない。例。
from mako.template import Template from mako.lookup import TemplateLookup with open("base.mako", "w") as w: w.write(""" <%block name="top"> base top bolck </%block> -------------------- <%block name="center"> base center bolck </%block> ------------------- <%block name="bottom"> base bottom bolck </%block> """) with open("inherit.mako", "w") as w: w.write(""" <%inherit file="./base.mako"/> <%block name="top"> inherit top </%block> <%block name="bottom"> ${self.inherits.bottom()} inherit top </%block> """) mylookup = TemplateLookup(directories=["."]) template = Template(filename="inherit.mako", lookup=mylookup) print template.render() ## output # inherit top # -------------------- # base center bolck # ------------------- # base bottom bolck # inherit top