This commit is contained in:
yumoqing 2020-12-11 12:12:21 +08:00
parent 0f479af41f
commit f039c242bb
2 changed files with 16 additions and 1 deletions

View File

@ -117,6 +117,22 @@ class TemplateProcessor(BaseProcessor):
else: else:
self.headers['Content-Type'] = 'text/html; utf-8' 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): class PythonScriptProcessor(BaseProcessor):
@classmethod @classmethod

View File

@ -40,7 +40,6 @@ class TemplateEngine(Environment):
def join_path(self,template: str, parent: str): def join_path(self,template: str, parent: str):
return self.loader.join_path(template, parent) return self.loader.join_path(template, parent)
def render(self,___name: str, **globals): def render(self,___name: str, **globals):
t = self.get_template(___name,globals=globals) t = self.get_template(___name,globals=globals)
return t.render(globals) return t.render(globals)