Is it possible to write an if statement based on a javascript variable with TWIG?
My first approach was this:
{% if info_message is defined %}
{% include 'includes/alerts/block.html.twig' with {'colorclass': 'danger', 'message': info_message} %}
{% endif %}
I want to create an alert based on a javascript variable, so is it possible to fill the info_message
with javascript and than render it with the message as variable?
I am using alerts like alerts.block.html.twig
:
<div class="alert alert-{{ colorclass }}">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
{% if raw is defined and raw %}
{{ message|raw }}
{% else %}
{{ message }}
{% endif %}