OK, but isn't there a way to pass the dictionary 'template' to the template 'default' such that this template refers to the 'base' macro in template['base']? Presently, the templates are read from a filesystem, but in future I would like to be able to read them from a (non-SQL) database. That's why I'm experimenting with string-based templates.

If not, I will investigate the PageTemplateFile option.

Thanks -- Nico


Op 10-08-15 om 19:42 schreef Malthe Borch:
String-based templates are really kind of awkward when it comes to "load". It's possible to wire it up, but you will need to do some work. It's easier to simply use PageTemplateFile because it has the "load" _expression_ compiler set up already.
On Mon 10 Aug 2015 at 19:36 Nico Poppelier <[email protected]> wrote:
Malthe,

Thanks for the quick reply! I read the documentation twice to find out what I was doing wrong. Did I miss a paragraph about load and file-based templates?

Anyway: my application uses string-based templates. The contents of all files *.xml are read when the application initializes, the resulting strings are passed to chameleon.PageTemplate, and the compiled templates are stored:

template['base'] = PageTemplate(read_file('base.xml'))
template['default'] = PageTemplate(read_file('default.xml'))

What is the best way for the 'default' template to refer to the 'base' template?

Regards, Nico

Op 10-08-15 om 18:13 schreef Malthe Borch:
Note that load is only available on file-based templates. Is that what you're using?
On Mon 10 Aug 2015 at 17:36 Nico Poppelier <[email protected]> wrote:
I'm trying to get template inheritance working they way it is described in this thread, but get the error message below when I try to load the templates: " LookupError: Unknown _expression_ type: 'load'."

Template 1: base.xml

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" metal:define-macro="base">
  <head><title>TITLE</title></head>
  <body>
  <div metal:define-slot="content">content</div>
  </body>
</html>

Template 2: default.xml
<div metal:use-macro="load: base.xml">
  <div metal:fill-slot="content">
  <p>one article as content</p>
  </div>
</div>

The files base.xml and default.xml are in the same directory.

Any help is appreciated!


Nico


--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to