Pylons

Loading
Pylons web application framework

Make Your Own Script Appender In Mako Templates

In a recently started Pylons project, I wanted to make an easy script appending facility in Mako templates.

The requirement:

  • base.mako contains the layout of the web page. Many templates inherit base.mako. Here's a snippet from base.mako
    <html>
    <head>
        <title>Some title</title>
        <script>...</script>
        <script>...</script>
    </head>
     
    </%def>
  • my_page.mako inherits base.mako. From within my_page.mako we want to be able to append script tags in the head section of the web page.

Syndicate content