How can I use a Twig if statement in a View rewrite How can I add a Views field rewrite using Twig that will display the moderation state only if the node is in draft state or review state? I tried the code below but it prints all of the moderation states.

{{ title_1 }}
{% if field.moderation_state == 'draft' %}Draft{% endif %}


This is how my list of titles look:

page1 Draft
page2 Published
page3 Submitted


I want all of the page titles to always display. I never want Published to display. So I want to first check if the moderation state is equal to draft and review.

I also tried variations like this

{% if moderation_state__value == 'draft' %}


Below are the available replacement pattters

   {{ moderation_state }} == Moderation state
   {{ path }} == Link to Content
   {{ title_1 }} == Title
   {{ title_1__value }} == Raw value
   {{ arguments.nid }} == Content: ID title
   {{ raw_arguments.nid }} == Content: ID input
You don't need to strip HTML tags. This works for me:
{% if field_tags == &quot;green&quot; %}
   GREEN
{% else %}
   NOT GREEN
{% endif %}

where field_tags is a taxonomy reference field with &quot;Link label to the referenced entity&quot; disabled.