wiki:DummyTemplate
Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 1 (modified by jorge.vargas, 11 years ago) (diff)

--

This is a clever idea I had that maybe someone else could find usefull

I'll like to thank David Stanek from the Kid discuss list that help me out, when my call to locals() recurse to infinity

So I wanted a kid template that will display any variable that I send to it, so later on a designer or myself will replace it with the real template.

so here it is.

<?python
def template_locals(template):
   for name, value in template.__dict__.iteritems():
        if not name.startswith('_') and not name.startswith('tg') and not name is "std":
            yield name, repr(value)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#">
    <head>
        <title>Welcome to TurboGears</title>
    </head>
    <body>
        <li py:for="var,val in template_locals(self)">
           <span>${var} = ${val}</span>
        </li>
    </body>
</html>

please note that the template_locals function maybe filter out whatever you like all that needs to be done is add more lines to that if.

peace