From 6a201362b3b08d84769f213fee0214f143eb6042 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 20 Jun 2017 17:49:44 +0100 Subject: [PATCH] fix sass support --- morpheus/app/extra/default-email-template.mustache | 2 +- morpheus/app/render/main.py | 2 +- morpheus/app/worker.py | 2 +- setup.py | 3 ++- tests/test_main.py | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/morpheus/app/extra/default-email-template.mustache b/morpheus/app/extra/default-email-template.mustache index 978f580f..10e63b02 100644 --- a/morpheus/app/extra/default-email-template.mustache +++ b/morpheus/app/extra/default-email-template.mustache @@ -3,7 +3,7 @@ {{ title }} - {{{ styles }}} +
diff --git a/morpheus/app/render/main.py b/morpheus/app/render/main.py index 9766f797..cfd36e0f 100644 --- a/morpheus/app/render/main.py +++ b/morpheus/app/render/main.py @@ -33,7 +33,7 @@ def _update_context(context, partials, macros): if k.endswith('__md'): yield k[:-4], markdown(v) elif k.endswith('__sass'): - yield k[:-6], sass.compile(string=v, output_style='compressed', precision=10) + yield k[:-6], sass.compile(string=v, output_style='compressed', precision=10).strip('\n') elif k.endswith('__render'): v = chevron.render( _apply_macros(v, macros), diff --git a/morpheus/app/worker.py b/morpheus/app/worker.py index 2c203766..65f8bc8b 100644 --- a/morpheus/app/worker.py +++ b/morpheus/app/worker.py @@ -98,7 +98,7 @@ async def send(self, subaccount=subaccount, important=important, ) - if re.search('\{\{\{ *styles *\}\}\}', main_template) and 'styles__sass' not in context: + if 'styles__sass' not in context and re.search('\{\{\{ *styles *\}\}\}', main_template): context['styles__sass'] = (THIS_DIR / 'extra' / 'default-styles.scss').read_text() drain = Drain( diff --git a/setup.py b/setup.py index 9cc07af4..bd058a29 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,8 @@ python_requires='>=3.6', zip_safe=True, install_requires=[ - 'misaka>=2.1.0', 'chevron>=0.10.0', + 'libsass>=0.13.2', + 'misaka>=2.1.0', ], ) diff --git a/tests/test_main.py b/tests/test_main.py index 8fc4fde7..29fc1d45 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -378,7 +378,8 @@ async def test_standard_sass(cli, tmpdir): message_id = data['uid'] + '-foobartestingcom' msg_file = tmpdir.join(f'{message_id}.txt').read() - assert '#body{-webkit-font-smoothing' in msg_file + print(msg_file) + assert '