example: overlay chain positive space

Let’s extend the simple example to add an intermediate template, so we
therefore have an overlay chain consisting of 3 templates, namely
overlay_chain_pos.html over overlay_mid.html
over the unmodified base.html (from simple example).

The templates

overlay_mid.html

$overlay{base.html}
        -ve space (overlay_mid.html)
$begin{footer}<span>overlay_mid footer</span>$end{footer}
        -ve space (overlay_mid.html)
  • an intermediate positive overlay on base.html
  • the -ve space from base.html is imposed
  • overrides one +ve block, #footer

overlay_chain_pos.html

$overlay{overlay_mid.html}
<html>
<head><title>template = ${title}</title></head>
<body>      <span> -ve space (overlay_chain_pos.html) </span>
  $begin{content} overlay_chain_pos ${parametrized} content $end{content}
  <div class="header">$evoque{#header}</div>
  <div class="content">$evoque{#content}</div>
  <div class="footer">$evoque{#footer}</div>
</body>
</html>
  • overrides the positive space of overlay_mid.html, redefining #content
  • when evoque’d directly, this template is rendered with:
    • the -ve space from below
    • own #content
    • the #header and #footer from below

Output

Rendering the overlay:

name = "overlay_chain_pos.html"
domain.get_template(name).evoque(title=name, parametrized="HAPPY")

Will give the following output (note negative space used is that from base.html):

<html>
<head><title>template = overlay_chain_pos.html</title></head>
<body>          <span> -ve space (base.html) </span>
  <table class="layout">
    <tr><td> +ve space: base header </td></tr>
    <tr><td> overlay_chain_pos HAPPY content </td></tr>
    <tr><td><span>overlay_mid footer</span></td></tr>
  </table>
</body>
</html>