Skip to content

Commit

Permalink
fix sass support
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Jun 20, 2017
1 parent 5852bc7 commit 6a20136
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion morpheus/app/extra/default-email-template.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{{ title }}</title>
{{{ styles }}}
<style>{{{ styles }}}</style>
</head>
<body marginheight="0" marginwidth="0">
<div style="display: none; visibility: hidden; font-size:1px;">
Expand Down
2 changes: 1 addition & 1 deletion morpheus/app/render/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion morpheus/app/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
)
3 changes: 2 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<style>#body{-webkit-font-smoothing' in msg_file


async def test_custom_sass(send_message, tmpdir):
Expand Down

0 comments on commit 6a20136

Please sign in to comment.