How to check a boolean value in twig templates? We have a field_boolean (boolean field) on an ECK Bundle on the article content type. While doing research we came across the question "How to test for a boolean field in a twig template?" but it does not solve my problem. 

What is the appropriate way to check for the boolean value?

We have attempted but they don't work:

{% if entity.field_boolean == True %}
{% if '1' in entity.field_boolean[0] %}


These appear to work, but not sure it is correct approach. 

{% if entity.field_boolean[#items].value == '1' %}
{% if entity.field_boolean[#items].value %}
Time for another promotion of my blogpost from a while ago :)

https://www.md-systems.ch/en/blog/techblog/2017/02/20/twig-and-entity-field-api-or-how-to-take-control-of-nodehtmltwig

The relevant part:

Only display a field if a checkbox is checked, optionally with custom wrapping HTML.

{% if node.field_checkbox.value %}
   &lt;div class="only added when there are values"&gt;
  {{ content.field_name }}
  &lt;/div&gt;
{% endif %}


You don't need == '1' or same as or anything like that, because it directly evaluates as to a boolean value. I also wouldn't recommend to use type safe checks with content entities because they are not type safe. Values are stored in the database and anything coming out from there is a string but sometimes values might not be. The boolean field is actually the perfect example for that, it is a string one, aka a nice mix of 3 different data types.