On Aug 21, 10:08 am, Mike Orr <[email protected]> wrote:
> It's doable.  The main issue is it's not "encapsulated"; each
> component would have to know more about all the other components than
> is desirable.  There are two main issues:
>
> 1) Adding the additional search paths.  For a group of applications
> sharing a set of base templates, you'd have to create a list of
> template directories in environment.py and pass that to
> TemplateLookup.  You could do it like this:
>
> ## environment.py
> template_paths = [paths['templates']]
> base_package.add_my_template_paths(template_paths)
> g.mako_lookup = TemplateLookup(directories=template_paths, ...)
>
> ## base_package
> def add_my_template_paths(template_paths):
>     p = os.path.join(os.path.dirname(__file__), "templates")
>     template_paths.append(p)
>
> 2) All template filenames must be unique across all components that
> are used together.  This can be satisfied by making a "/base"
> subdirectory in the base template path, and putting all base templates
> under that.  No other component would have a /base subdirectory.  Then
> the templates would inherit thus:
>
> <% inherit file="/base/site.html" />
>
> --
> Mike Orr <[email protected]>

Thank, that was what I was looking for.  Especially #2.

I was thinking of structuring the template directories much like the
site relations.  There will one or more templates ALL the sites
inherit, and then the sites will be grouped by 'family'.  Each family
directory would have a family_base to inherit, then within the family
directory, site directories.  Each template within the site directory
could always be prefaced by the site name (i.e. site1_view.mako,
site1_frontPage.mako, etc).

Something like:

|-templates
  |- Master_base.mako
  |- Family1
  |   |- Family1_base.mako
  |   |- Site1
  |   |   |- Site1_view.mako
  |   |   |- Site1_frontPage.mako
  |   |
  |   |-  Site2
  |       |- and so on
  | - Family2
      |- Family2_base.mako
      |- Site3
          |- and so on


Thanks for you input.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to