When an email campaign fails to render, a Jinja rendering error may appear. If the error message begins with Unexpected char '&', it usually means an HTML entity using & character, for example, a non-breaking space was inserted inside a Jinja block.
Cause
Jinja syntax is strict about the characters it accepts inside its expression and statement blocks {{ }} and {% %}. If the error message shows Unexpected char '&', it means the & character is present inside a Jinja block where it is not expected, so the template fails to render.
The error message points to the exact line and location where the & character appears.
For example:
In the above image, the non-breaking space, represented by is between line 5 and the enclosing of the Jinja statement brackets %}.
Fix
Read the error message carefully, noting the line number and the surrounding code snippet it references.
Open the email template editor and navigate to the indicated line.
Locate the
&character flagged in the error within the Jinja block and delete it.Check the rest of the template for any other similar invalid characters inside Jinja expression
{{ }}or statement{% %}blocks and remove them.Re-render the email to confirm the error is resolved.
Note
can still be used in normal HTML content outside Jinja blocks. The issue is its placement inside Jinja syntax.