Unable to render template
When running mjml-python I get this error that I do not get compared to running : ./node_modules/.bin/mjml index.mjml input.mjml -o output.html
Value Example:
<mjml>
<mj-head>
<mj-title>Your order has been cancelled!</mj-title>
<mj-attributes>
<mj-all padding="0px"></mj-all>
<mj-text font-family="Roboto, Helvetica, sans-serif" font-size="14px"></mj-text>
<mj-table font-family="Roboto, Helvetica, sans-serif" font-size="14px"></mj-table>
<mj-section background-color="#ffffff"></mj-section>
<mj-wrapper background-color="#ffffff"></mj-wrapper>
</mj-attributes>
<mj-style inline="inline">
.summary-header {
color: #85807f;
font-size: 16px;
}
.delimited {
border-bottom: 1px solid #b8b8b8;
}
.delimited > td {
padding-bottom: 16px;
}
.extra-info {
margin-top: 8px;
}
.cost {
font-weight: bold;
padding-left: 1em;
text-align: right;
vertical-align: top;
white-space: nowrap;
}
.total {
text-align: right;
font-size: 24px;
font-weight: bold;
}
table {
margin: 0 auto;
border-collapse: collapse;
font-family: Roboto, Helvetica, sans-serif;
}
td {
padding-top: 16px;
}
.bottom-spacer {
height: 3rem;
}
</mj-style>
<mj-style inline="inline">
.footer-text div {
font-size: 11px !important;
color: #000000 !important;
text-align: center !important;
}
</mj-style>
</mj-head>
<mj-body background-color="#dddddd">
<!-- Email Header -->
<mj-section>
<mj-column width="100%">
<mj-image src="https://www.foodandwine.com/thmb/DI29Houjc_ccAtFKly0BbVsusHc=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/crispy-comte-cheesburgers-FT-RECIPE0921-6166c6552b7148e8a8561f7765ddf20b.jpg" alt="" padding="0px"></mj-image>
</mj-column>
</mj-section>
<!-- Email Content -->
<mj-wrapper padding="20px">
<mj-section>
<mj-raw>{% for item in items %} </mj-raw>
<mj-column width="80%">
<mj-text>{{ item.title }}</mj-text>
<mj-image src="{{ item.image }}" alt="" padding="0px"></mj-image>
</mj-column>
<mj-raw>{% endfor %}</mj-raw>
</mj-section>
</mj-wrapper>
<!-- Footer -->
<mj-section padding-bottom="20px">
<mj-column>
<mj-text css-class="footer-text" padding-top="40px">
Copyright © All rights reserved.
</mj-text>
<mj-text css-class="footer-text" padding-top="10px">
<a href="/terms">Terms and Conditions</a>
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
If I pass the string directly I get:
Traceback (most recent call last):
File "lib/python3.9/site-packages/mjml/mjml2html.py", line 79, in mjml_to_html
mjBody = mjml_root('mj-body')[0]
TypeError: 'NoneType' object is not callable
If I save the value to a file then I get:
results = mjml_to_html(rendered_html)
File "lib/python3.9/site-packages/mjml/mjml2html.py", line 230, in mjml_to_html
raise ImportError('CSS inlining is an optional feature. Run `pip install -e ".[css_inlining]"` to install the required dependencies.') # noqa: E501
ImportError: CSS inlining is an optional feature. Run `pip install -e ".[css_inlining]"` to install the required dependencies.
When I run pip install, I get:
ERROR: Could not find a version that satisfies the requirement css_inlining (from versions: none)
ERROR: No matching distribution found for css_inlining
Again, I don't get this error when using node.
I have to say that it works for me, even with Python 3.9 (using Fedora Linux here). Which operating system are using?
Could you try creating a fresh virtualenv and installing the latest version of mjml?
And last but not least you could try relaxing the css_inline requirement and install the latest version.
I can not reproduce the problem locally. Feel free if you can reproduce the problem with the latest version of mjml.