Mercurial > genshi > mirror
comparison genshi/template/plugin.py @ 784:ea46fb523485 experimental-match-fastpaths
update to 0.5.x branch, up through r907
don't know how this fits in with SoC work, but I wanted to do due diligence and keep this branch working in case it someday gets considered for trunk
author | aflett |
---|---|
date | Mon, 21 Jul 2008 23:17:52 +0000 |
parents | badb73198fb1 |
children |
comparison
equal
deleted
inserted
replaced
724:919809e55d16 | 784:ea46fb523485 |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # | 2 # |
3 # Copyright (C) 2006-2007 Edgewall Software | 3 # Copyright (C) 2006-2008 Edgewall Software |
4 # Copyright (C) 2006 Matthew Good | 4 # Copyright (C) 2006 Matthew Good |
5 # All rights reserved. | 5 # All rights reserved. |
6 # | 6 # |
7 # This software is licensed as described in the file COPYING, which | 7 # This software is licensed as described in the file COPYING, which |
8 # you should have received as part of this distribution. The terms | 8 # you should have received as part of this distribution. The terms |
13 # history and logs, available at http://genshi.edgewall.org/log/. | 13 # history and logs, available at http://genshi.edgewall.org/log/. |
14 | 14 |
15 """Basic support for the template engine plugin API used by TurboGears and | 15 """Basic support for the template engine plugin API used by TurboGears and |
16 CherryPy/Buffet. | 16 CherryPy/Buffet. |
17 """ | 17 """ |
18 | |
19 from pkg_resources import resource_filename | |
20 | 18 |
21 from genshi.input import ET, HTML, XML | 19 from genshi.input import ET, HTML, XML |
22 from genshi.output import DocType | 20 from genshi.output import DocType |
23 from genshi.template.base import Template | 21 from genshi.template.base import Template |
24 from genshi.template.loader import TemplateLoader | 22 from genshi.template.loader import TemplateLoader |
89 return self.template_class(template_string) | 87 return self.template_class(template_string) |
90 | 88 |
91 if self.use_package_naming: | 89 if self.use_package_naming: |
92 divider = templatename.rfind('.') | 90 divider = templatename.rfind('.') |
93 if divider >= 0: | 91 if divider >= 0: |
92 from pkg_resources import resource_filename | |
94 package = templatename[:divider] | 93 package = templatename[:divider] |
95 basename = templatename[divider + 1:] + self.extension | 94 basename = templatename[divider + 1:] + self.extension |
96 templatename = resource_filename(package, basename) | 95 templatename = resource_filename(package, basename) |
97 | 96 |
98 return self.loader.load(templatename) | 97 return self.loader.load(templatename) |