diff -r 6d87fbbfc10a -r a0816159a647 roundup/cgi/engine_jinja2.py --- a/roundup/cgi/engine_jinja2.py Thu Jun 18 15:36:58 2015 +0300 +++ b/roundup/cgi/engine_jinja2.py Mon Jun 22 17:21:40 2015 +0300 @@ -53,7 +53,7 @@ self._env.filters.update(additional_filters) def check(self, tplname): - #print tplname + tplname = self.reformTplName(tplname) try: #print self._env.get_template(tplname + '.html') self._env.get_template(tplname + '.html') @@ -64,6 +64,7 @@ def load(self, tplname): #src, filename = self.check(tplname) + tplname = self.reformTplName(tplname) return Jinja2ProxyPageTemplate(self._env.get_template(tplname + '.html')) def precompile(self): diff -r 6d87fbbfc10a -r a0816159a647 roundup/cgi/templating.py --- a/roundup/cgi/templating.py Thu Jun 18 15:36:58 2015 +0300 +++ b/roundup/cgi/templating.py Mon Jun 22 17:21:40 2015 +0300 @@ -106,6 +106,39 @@ """ raise NotImplementedError + def reformTplName(self, tplname): + """ Exract subdir part from tplname. + Use this to allow subdirectories in template name, + such as "@template=mobile/index". + Canonized tplname prefixed by subdirs is returned + + tplname formed as classname.templatename, + so url "/issue?@template=mobile/index" transformed + by selectTemplate function to tplname value: + issue.mobile/index + This function with such argument will return: + mobile/issue.index + """ + # may be, do nothing? + if '/' not in tplname: + return tplname + + (classname, viewpart) = tplname.split('.', 1) + + vparts = viewpart.split('/') + if len(vparts) < 2: + # this is not the case we work on + return tplname + # allow '/' in prefix + if not vparts[0]: + del vparts[0] + + # put the last element (view name) back in canonical form + vparts[-1] = classname + '.' + vparts[-1] + + return os.path.join( *vparts ) + + class TALLoaderBase(LoaderBase): """ Common methods for the legacy TAL loaders."""