O'Reilly logo

Python 2.6 Text Processing Beginner's Guide by Jeff McNeil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - converting mail message to use namespaces

In this example, we'll create another template and move our current def into it. Additionally, we'll move some of the reusable logic out of our main template and into our new file. We can then access the def blocks within our new template via the namespace tag.

  1. Create a new template file within the templates directory and name it base.txt. Ensure that it has the following content:
     <%def name="line_item(name, quantity, descr, used)">\ ## Render a Single Line Item * ${name} Quantity: ${quantity} Description: ${descr} %if used: Note: This is a refurbished item. %endif </%def> <%def name="footer()">\ High Quality Widgets, Inc. http://www.highqualitywidgets.com support@highqualitywidgets.com ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required