Ian Bicking a écrit :
The only concern I have is that it might be harder to implement or map to systems that already have a concept of a search path. It shouldn't be implemented purely on the frontend, because all templates (including included or extended templates) should be found with the same mechanism.
Right suggestion 6. doesn't work for include and extends by suggestion 7 works for every case.7. instead of set/copy configuration data into the template engine, initialisation sets/"injects" the function. function with 2 parameters : the template-location and the file extension for template file. In this case I prefer the **kw (2) for injecting the function.
class TemplatePlugin:
def __init__(self, extra_vars_func = None, options = {}, find_template =
None, **kw):
...
self.find_template = find_template
...
def load_template(self, templatename):
template_path = find_template(templatename, ".tmpl")
With this TG could choose the strategie/implementation for the find_template
function.
Current implementation is:
def pkg_template(templatename, ext):
divider = templatename.rfind(".")
if divider > -1:
package = templatename[0:divider]
basename = templatename[divider+1:]
return pkg_resources.resource_filename(package, "%s.%s" % (basename, ext))
And Plugin could choose to have an other mecanisme.
--
--------------------------------------------------------------
David "Dwayne" Bernard Freelance Developer
signature.asc
Description: OpenPGP digital signature

