Sorry, I ran into another problem :( If I use files instead of variables it does not work anymore. I attached an example. Do you have an idea? Seems as if the namespace "ns" is not passed correctly... but thats just an idea.
Dirk Christoph Zwerschke schrieb:
Dirk Holtwick wrote:Do you have an idea why the example fails and how I could solve this problem? I have the impression that Kid is focused more on files than on strings? Help is very appreciated.I tested a little bit and I think the reason is that load_template is not reentrant or something. It works if you do it like that:------------- master = """\ <html xmlns:py="http://purl.org/kid/ns#"> <body py:match="item.tag == 'body'"> <p>my header</p> <div py:replace="item[:]" /> <p>my footer</p> </body> </html>""" page = """\ <html py:extends="master" xmlns:py="http://purl.org/kid/ns#"> <body> <p>my content</p> </body> </html>""" class KidTemplateManager: def __init__(self, master): self.master = None self.master = self.load(master) def load(self, source): import kid return kid.load_template(source, cache=False, ns=dict(master=self.master)) template = KidTemplateManager(master).load(page) print template.serialize() -------------I'd like to make a ticket of this to investigate further, but the trac is still broken and I still can't log in (@David: hint, hint!).-- Christoph ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ kid-template-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kid-template-discuss
class KidTemplateManager:
def __init__(self):
self.pool = []
def load(self, path):
print "Getting", path
import kid
source = open(path, "rb").read()
template = kid.load_template(
source,
cache=False,
ns=dict(load=self.load))
self.pool.append(template)
return template
template = KidTemplateManager().load("index.html")
print template.serialize()

my content
| 
my header my footer |
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ kid-template-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kid-template-discuss
