'How to fix HTML in Alpine.js dispatch when using in a WP Gutenberg block

I've been using a Alpine and its $dispatch-function on click to fill a modal with a title and text, dependent on what button is pressed. When I add this dispatch to a piece of code that is being used in a Wordpress Gutenberg block, I am not able to use HTML, since it breaks everything that comes after it.

My @click function:

@click="$dispatch('modal', { title: 'Tilmeld åbent <i>hus</i>', message: 'Udfyld formularen herunder og tilmeld dig åbent hus for <strong> <?= $address; ?> </strong>'});"

How do I fix this, so my block doesn't break, but the text is still displayed in my modal?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source