Joshua Kifer schrieb:
> What I'd like to do is provide a match for a tag instead such that
> having defined a match against the tag name 'blog-entry' I could place
> in my code:
>
> <kid py:match="item.tag = 'blog-entry'" py:strip="True">
> <div class="blog-entry">
> <div class="blog-header">
> <a class="blog-title" href="$entry.Link">$entry.Title</a>
> <a class="blog-permalink" href="/blog/entry/$entry.ID">z</a>
> </div>
> <div class="blog-body">
> ${XML(md.convert(entry.Body))}
> </div>
> </div>
> </kid>
>
> <div class="content">
> <kid py:for="entry in session.query(BlogEntry).all()"
> py:strip="True">
> <blog-entry/>
> </kid>
> </div>
>
> In this case, it doesn't work because the entry records are not being
> scoped into the evaluation of the blog-entry element.
Ok, now I understand what you want.
Due to the way how Kid works this is probably very difficult to
implement. However, you have 3 different options as workaround for
passing your parameters to match templates: 1) As part of the item
itself, 2) as template attributes, or 3) as global attributes:
-- Option 1 ---
<div py:match="item.tag == 'blog-entry'" class="blog-entry">
<div class="blog-header">
<a class="blog-title" href="${item.get('link')}"
py:content="item.get('title')"/>
<a class="blog-permalink" href="/blog/entry/${item.get('id')}">z</a>
</div>
<div class="blog-body" py:content="item[:]"/>
</div>
<div class="content">
<blog-entry py:for="entry in session.query(BlogEntry).all()"
id="$entry.ID" link="$entry.Link" title="$entry.Title"
py:content="XML(md.convert(entry.Body))"/>
</div>
-- Option 2 ---
<div py:match="item.tag == 'blog-entry'" class="blog-entry">
<div class="blog-header">
<a class="blog-title" href="$self.entry.Link"
py:content="self.entry.Title"/>
<a class="blog-permalink"
href="/blog/entry/$self.entry.ID">z</a>
</div>
<div class="blog-body" py:content="XML(md.convert(self.entry.Body))"/>
</div>
<div class="content">
<blog-entry py:for="self.entry in session.query(BlogEntry).all()"/>
</div>
--- Option 3 ---
<div py:match="item.tag == 'blog-entry'" class="blog-entry">
<div class="blog-header">
<a class="blog-title" href="$entry.Link"
py:content="entry.Title"/>
<a class="blog-permalink"
href="/blog/entry/$entry.ID">z</a>
</div>
<div class="blog-body" py:content="XML(md.convert(entry.Body))"/>
</div>
<div class="content">
<?python global entry ?>
<blog-entry py:for="entry in session.query(BlogEntry).all()"/>
</div>
------------------
-- Christoph
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kid-template-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kid-template-discuss