feat: add charset utf-8 to html response and pass context to template renderer

This commit is contained in:
retoor 2025-01-27 22:31:08 +00:00
parent aaf5639826
commit f16ac21bbd

View File

@ -57,9 +57,11 @@ class TemplateView(BaseView):
context['json'] = None
if str(path.endswith('.md')):
renderer = MarkdownRenderer(self.request.app, path)
return web.Response(text=renderer.render(),content_type="text/html")
return web.Response(text=renderer.render(), content_type='text/html', charset='utf-8', **context)
return await super().render_template(path, self.request)
reponse = await super().render_template(path, self.request, context)
response.headers['Content-Type'] = 'text/html'
return response
async def get(self):
path = await self.resolve_template(self.request.match_info['tail'])