Jinja FAQ

How do I solve the error showing the Unexpected char '&'?



When an email fails to render and gets stuck in the loading phase with an error, it means there is a blank space in the code where it is not expected. Jinja syntax is sensitive to such errors and fails to execute.

Additionally, if the error starts with Unexpected char ‘&’, check the error message to locate the part of the code where the character ‘&’ is contained. For example, in the above image, the blank space (indicated by “ ” or non-breaking space) is between the number 5 and the enclosing of the jinja expression brackets.


Once you have located the blank space, go back to the code in the editor and delete the blank space. Similarly, check and delete other blank spaces indicated in error and render the email once again.

How do I solve an error stating None has no attribute value?

588 533


When an error occurs with a message similar to None/None type has no attribute/None has no attribute value, as displayed in the image above, it means that an empty object has been accessed. This can happen in a scenario where the code contains a variable that is expected to be added with an object (such as an item for a catalog based on its ID), but the code fails to do so.

For example, providing a non-existent item_id which causes the item_by_id function to fail to fetch any item from the catalog. When working with the same object later, rendering fails as the object does not exist.


When encountering such an error, it is recommended to add a condition that checks whether the object exists or not. This practice can avoid unnecessary rendering issues.

Conditions are added to the code in the above image (see the image below). This condition prevents incorrect access to the object in case it does not exist. The {% if item%} results in True if there is a value assigned to the variable. If the result is False, the execution of the code within is not executed if the code calls for the given object.

520 642