Hi all,
I'm - gradually! - getting my head wrapped around Kid templates but have hit a puzzling behavior.
Here's what I've got:
master.kid:
=== snip ===
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?python import sitetemplate ?>
<?python page_title = "" ?>
<html xmlns="
http://www.w3.org/1999/xhtml" xmlns:py="
http://purl.org/kid/ns#" py:extends="sitetemplate" lang="en">
<head py:match="item.tag=='{
http://www.w3.org/1999/xhtml}head'">
<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
<link rel="stylesheet" href="css/base.css" type="text/css" />
<link rel="home" title="Home" href="
http://www.grimmlabs.com/
" />
<title>${page_title}</title>
</head>
... etc ...
=== snip ===
And home.kid:
=== snip ===
<!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#" py:extends="'master.kid'" lang="en">
<?python page_title = "Home Page" ?>
<head></head>
... etc ...
=== snip ===
What I'm trying to do is make it so that I don't have to re-create my <head> element in every template that I create, since that will be mostly consistent for all pages. HOWEVER, the <title> will have to be different for every page.
Since TITLE is embedded in HEAD I can't substitute it in the 'home' template without providing my own 'head' element for each template. So what I thought I could do is use the python variable 'page_title' in the 'home' template and that would be substituted into the included header.
That's not happening. If I use what's above, the <title> element is empty. If I don't define it as "" in the master template, then an exception is thrown.
BUT
If I do something like this:
@turbogears.expose(html="grimmlabs.templates.home")
def index(self):
return dict(page_title="Home Page",)
then it gets filled in properly.
I can LIVE with the way it's working, but I would PREFER to keep as much in the template itself and save myself a bunch of trivial stuff in the code itself.
Any ideas?
(note: it may be obvious to you. Assume it's not to me. 'cause it ain't.)
--
"Things fall apart. The Center cannot hold."
- Life as a QA geek, in a nutshell.
Best,
Jeff