Posted By

wackysalut on 02/17/08


Tagged

templates inheritance pylons mako


Versions (?)

Insert stuff into from any subtemplate


 / Published in: HTML
 

This allows you to collect some snippets of or tags from any subtemplate, and place them in the of your base template, no matter how you skip some templates in the chain.

Note how you could skip the definition of head() in the layout1_base.html file.

  1. ## base.html
  2. <head>
  3. <!-- blah blah -->
  4. ${self.head()}
  5. </head>
  6. <%def name="head()">
  7. ## Base definition (empty), override in subtemplates, and call
  8. ## ${parent.head()} somewhere in your definition.
  9. </%def>
  10.  
  11.  
  12. ## layout1_base.html
  13. <%inherit file="base.html" />
  14.  
  15. <%def name="head()">
  16. ${parent.head()}
  17. <script type="text/javascript" src="/js/mootools.v1.11.js"></script>
  18. </%def>
  19.  
  20.  
  21. ## view for controller X
  22. <%inherit file="layout1_base.html" />
  23. <%def name="head()">
  24. ${parent.head()}
  25. <link rel="stylesheet" type="text/css" href="/css/woohoo.css" />
  26. </%def>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: wackysalut on February 17, 2008

Into the "HEAD" element of the HTML tag, sorry, the site removed it in the title.

You need to login to post a comment.