If your HTML block or snippet preview shows email is undefined, this usually does not mean the block is broken.
The most common reason is that email-specific Jinja variables, such as email.view, are only available in an email template context. In a standalone block or snippet preview, the email object does not exist, so the preview cannot resolve those variables.
Why this happens
HTML blocks can be reused in different contexts. According to the HTML blocks documentation, contextual variables such as event, webhook, or email.view are not available directly inside the block itself. They can only be passed and resolved in campaigns where those variables are available.
Because of this, previewing a block or snippet on its own can show an email is undefined error even when the same content works correctly after it is inserted into an email.
What this means in practice
email.view,email.unsubscribeand similar email variables are expected to work only when the block is used inside an email template.The standalone block preview does not fully simulate the email object.
This is a preview limitation, not necessarily a problem with your block code.
How to test the block correctly
Instead of relying on the standalone block preview, test the block inside an email template context:
Insert the block or snippet into an email template or campaign.
Open the email preview or test view.
Send a test email if needed.
Confirm that the email-specific variable renders correctly there.
This is the recommended workaround when your block contains email-only variables.
Can I still use the block?
Yes. If the block renders correctly after being placed into an email, you can continue using it even if the standalone block preview shows email is undefined.
Optional workaround
If you want to avoid the preview error while editing the block on its own, you can use a fallback Jinja template so the block has a placeholder value outside the email context. For example:
{{ email.view if email is defined else "#" }}This can make standalone previewing easier, but it is only a workaround. The more reliable test is still to validate the block inside a real email.
Summary
A standalone block preview does not provide the email template context. If your block uses email.view or other email-specific variables, test it in an email template or campaign rather than relying on the block preview alone.