On Fri, Aug 21, 2009 at 9:38 AM, vizbones<[email protected]> wrote:
>
> I'm currently working on a project which will consist of several
> different, but related web-sites. Each site will need to be its own
> Pylons app, but they will all have a common look 'n feel. I would
> like to leverage the inheritance mechanism of mako templates to
> achieve this common look 'n feel without too much code replication.
>
> So, has anyone ever shared a template set across different Pylons apps
> before?
> Do people think it's 'doable'?
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]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---