From 623bcd6a3209ae4359a373dd689ca148947989dd Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Sat, 7 Mar 2020 15:19:35 -0500 Subject: [PATCH] minor fixes --- IzzyLib/color.py | 3 +++ IzzyLib/template.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/IzzyLib/color.py b/IzzyLib/color.py index ba6fca7..9e1a019 100644 --- a/IzzyLib/color.py +++ b/IzzyLib/color.py @@ -1,6 +1,9 @@ '''functions to alter colors in hex format''' +import re + from colour import Color + check = lambda color: Color(f'#{str(color)}' if re.search(r'^(?:[0-9a-fA-F]{3}){1,2}$', color) else color) def _multi(multiplier): diff --git a/IzzyLib/template.py b/IzzyLib/template.py index 2f9ccb7..e238a3f 100644 --- a/IzzyLib/template.py +++ b/IzzyLib/template.py @@ -4,7 +4,7 @@ import codecs, traceback, os, json, aiohttp from os import listdir, makedirs from os.path import isfile, isdir, getmtime, abspath -from jinja2 import Environment, FileSystemLoader, ChoiceLoader +from jinja2 import Environment, FileSystemLoader, ChoiceLoader, select_autoescape from hamlpy.hamlpy import Compiler from markdown import markdown @@ -100,7 +100,10 @@ def delEnv(var): def setup(): global env env = Environment( - loader=ChoiceLoader([FileSystemLoader(path) for path in search_path]) + loader=ChoiceLoader([FileSystemLoader(path) for path in search_path]), + autoescape=select_autoescape(['html', 'css']), + lstrip_blocks=True, + trim_blocks=True ) @@ -116,7 +119,7 @@ def renderTemplate(tplfile, context, request=None, headers=dict(), cookies=dict( def aiohttpTemplate(*args, **kwargs): - ctype = kwargs.get('contentType', 'text/html') + ctype = kwargs.get('content_type', 'text/html') status = kwargs.get('status', 200) html = renderTemplate(*args, **kwargs) return aiohttp.web.Response(body=html, status=status, content_type=ctype)