> Yes, and it's easy to debug normal function calls! It's well worth
> turning on the environment variable that leaves the generated python
> files on disk (KID_OUTPUT_PY) (make sure you have the latest from svn
> with the patch to make that work in normal operation). Then you can look
> at the code at the line numbers it prints in the stack trace to see
> what's going on.
I'll definitely have to have a look at that - I've often wondered where
these magical errors keep coming from. ;)
> >Still, I think the macro/slot concept is really good and it has no
> >equivalent in Kid (yet). Again, if I wanted Zope or Plone with all its
> >issues, I'd use Zope or Plone :)
>
> I agree! Kid's flexible enough that you can write a simple slot filling
> system in Python, as utilities in the base template class from which
> your templates inherit. It's possible to layer a higher level template
> system on top of kid in this way, without compromising the simplicity of
> the core system.
Well, it seems that after a day of tinkering in my spare time at work,
I have found a partial solution. A pretty good partial solution, but
still a little bit backwards. The following snippits will give you
slots which can have a default value:
- master.kid -
<html ...>
<!-- the following are separated to allow differing default content
-->
<div py:def="leftSlot">left slot default content goes here</div>
<div py:def="rightSlot">right slot default content goes here</div>
<body py:match="{...}body>
<div py:replace="item[:]" />
<div py:replace="leftSlot()" />
<div py:replace="rightSlot()" />
</body>
</html>
- page.kid -
<html ...>
<div py:def="leftSlot">real left slot content goes here</div>
<body>
<p>Bob Dole!</p>
</body>
</html>
- result.html -
<html ...>
<body>
<p>Bob Dole!</p>
<div>real left slot content goes here</div>
<div>right slot default content goes here</div>
</body>
</html>
> Good news: you can return a dict with a key tg_template that names the
> template you want to use, which overrides the template declared in the
> @turbogears.expose wrapper! That's handy for returning error messages
> and redirecting to other templates.
I certainly hope there is a similar dict-based argument that can
override Identity permission requirements. I would like to
programatically protect certain pages based off of, say, SQLObject
criteria. But that's a different issue. ;)
> It would be nice to be able to pass the content of the calling element
> to functions defined by py:def, so you can do lisp-macro-like stuff like
> defining your own control structures.
content() anyone? That link several posts up to
http://lesscode.org/projects/kid/ticket/62 provides an interesting
idea.
> I think Kid is an excellent and sound design, which can be extended to
> support what you need by inheriting from optional utility templates,
> without spoiling its wonderful simplicity.
Agreed. Kid is one of the best templating systems I have ever worked
with.