From f039c242bb4e4118bab2f2e7e7d252427c2a0c2f Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 11 Dec 2020 12:12:21 +0800 Subject: [PATCH] bugfix --- ahserver/baseProcessor.py | 16 ++++++++++++++++ ahserver/myTE.py | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ahserver/baseProcessor.py b/ahserver/baseProcessor.py index 726a317..c64c78b 100644 --- a/ahserver/baseProcessor.py +++ b/ahserver/baseProcessor.py @@ -117,6 +117,22 @@ class TemplateProcessor(BaseProcessor): else: self.headers['Content-Type'] = 'text/html; utf-8' +class JSUIProcessor(TemplateProcessor): + @classmethod + def isMe(self,name): + return name=='jsui' + + async def datahandle(self, request): + params = await self.resource.y_env['request2ns']() + if params.get('_jsui',None): + super().datahandle(request) + else: + ns = self.run_ns + te = self.run_ns['tmpl_engine'] + content0 = te.render('/header.tmpl',**ns) + content1 = te.render(self.path, **ns) + content2 = te.render('/footer.tmpl',**ns) + self.content = '%s%s%s' % (content0,content1,content2) class PythonScriptProcessor(BaseProcessor): @classmethod diff --git a/ahserver/myTE.py b/ahserver/myTE.py index 66d251d..2971907 100644 --- a/ahserver/myTE.py +++ b/ahserver/myTE.py @@ -40,7 +40,6 @@ class TemplateEngine(Environment): def join_path(self,template: str, parent: str): return self.loader.join_path(template, parent) - def render(self,___name: str, **globals): t = self.get_template(___name,globals=globals) return t.render(globals)