Chapter 13.2.1. Transformations Using py:match

There are a number of advantages to the py:match approach, but perhaps the most important is that it takes only a single line of code per page to get headers, footers, sidebars, and other page elements inserted into your page.

You can use py:match to automatically add JavaScript or CSS references to all your pages, or even to add sidebars and other content to the body of all your pages. You can even use py:match to create custom tags like Java’s taglibs.

Given all that power, it can take a while to work your mind around how py:match works. Conceptually it’s simple: py:match searches through the rest of your template for matching elements and replaces them with the contents of the element to ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.