Howdy!
So far I have found two ways to easily template my site:
1. Use py:match in the master.kid and appropriate elements in the page.
http://lesscode.org/projects/kid/wiki/LayoutTemplateRecipe
2. Use py:def to define function in the page and have the master.kid
pull the sections from the current document. (Requires in-line Python,
which is bad.)
http://lesscode.org/projects/kid/wiki/DefBasedLayoutTemplateRecipe
3. I want to use py:def to define "wrappers" in the master.kid, and
allow the page to call the sections with something more than simple
arguments. E.g. I want to give the defined function access to the sub
elements a la py:match's automatic 'item' variable.
> <?xml version="1.0" encoding="utf-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#">
> <div py:def="slot(element)" class="metal-slot"
> py:attrs="'id': 'metal-%s-slot' % element.get('id')">Testing!</div>
>
> <head>
> <title></title>
> </head>
> <body>
> <div py:replace="slot(this)" id="left">
> Bob Dole!
> </div>
> </body>
> </html>
4. In a perfect world, I want the following:
- master.kid -
> <?xml version="1.0" encoding="utf-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#">
> <head>
> <title></title>
> </head>
> <body>
> <div id="required-header">... site header ...</div>
> <div py:slot="top">... default top slot ...</div>
> <div id="content-wrapper">
> <div py:slot="content" /><!-- no default - if not filled, remove -->
> <div py:slot="right">... default right slot ...</div>
> <div py:slot="left">... default left slot ...</div>
> </div>
> <div id="required-footer">... site footer ...</div>
> </body>
> </html>
- page.kid -
> <?xml version="1.0" encoding="utf-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
> py:extends="'master.kid'">
> <body>
> <div py:fill="content">
> ...
> </div>
> </body>
> </html>
Does anyone know how to do that last item using existing Kid technology
(i.e. crafty use of py:match?) As py:match stops on the first hit
(i.e. if <body> matches, nothing within is matched) this would seem
problematical.
Are there other solutions I could use to provide this level of
flexability? I.e. another templating system embedding Kid?