PyMeld for html templates?

Sean Schertell sean at datafly.net
Sun Jan 21 19:03:55 EST 2007


Thanks Richie! That's exactly the reply I was hoping for.

Hooray!

Sean



On Jan 20, 2007, at 9:50 PM, Richie Hindle wrote:

> Hi Sean,
>
>> Thanks Richie -- but actually, what I had in mind was slightly
>> different. I want for my CONTENT pages to only contain the content.
>> So to modify your example:
>>
>> LAYOUT = """<html><head><title id='title'>The Title</title></head>
>> <body><div id='info'>The page information goes here.</div>
>> <p id='footer>Copyright Me 2007.</p></body></html>"""
>>
>> INFO = """<div id='info'><p>Here is the info, which would in the real
>> world
>> be read from a file.</p></div>"""
>>
>> Can I do this just as easily?
>
> Yes, of course, just the same way:
>
> from PyMeld import Meld
>
> LAYOUT = """<html><head><title id='title'>The Title</title></head>
> <body><div id='info'>The page information goes here.</div>
> <p id='footer>Copyright Me 2007.</p></body></html>"""
>
> INFO = """<div id='info'><p>Here is the info, which would in the real
> world be read from a file.</p></div>"""
>
> page = Meld(LAYOUT)
> info = Meld(INFO)
> page.info = info.info._content
> print page
>
> There's nothing that says a Meld has to be a complete HTML document.
>
>> One other unrelated question... Let's say I have a table with a
>> template row with id="myRow". I want to use PyMeld to clone that row
>> n number of times (depending on database results). So here's my
>> stoopid question: Does that mean that my XHTML will contain n rows
>> all with the same id="myRow" thereby making my XHTML invalid?
>
> Yes, it does, but you can simply delete the 'id' attributes from  
> the rows,
> with `del row.id`, before adding them back into the document.
>
> -- 
> Richie Hindle
> richie at entrian.com





More information about the Python-list mailing list