I am using Drupal 8. I have a paragraphs field (field type: paragraphs of reference revisions) in node template, I tried lots of ways to check if the field is empty (purpose is to show the field only it has a value).
<code> {# Below codes in node.html.twig #} {# Below codes NOT work #} {% if content.field_notes.0 is empty %} This field is empty-1. {% endif %} {% if content.field_notes[0] is empty %} This field is empty-2. {% endif %} {# Enable module:twig field value #} {% if content.field_notes|field_value is empty %} This field is empty-3. {% endif %} {% if node.field_notes.isempty %} This field is empty-4. {% endif %} {% if node.field_notes.value is empty %} This field is empty-5. {% endif %} </code> How can check if a paragraphs field is empty in node template in Drupal 8?
UPDATE: Codes tested and result below, the way NOT work for paragraphs but work for some other field types.
{% set count_field_element_1 = node.field_paragraphs|length %} {{ count_field_element_1 }} {# when field has or no value: count_field_element_1 = 2 #} {# paragraphs type contains two field type: image and text plain long #}
{% set count_field_element_2 = node.field_image|length %} {{ count_field_element_2 }} {# when field has value: count_field_element_2 = 1; #} {# when field has no value: count_field_element_2 = 0; #}
{% set count_field_element_3 = node.field_text_plain_long|length %} {{ count_field_element_3 }} {# when field has value: count_field_element_3 = 1; #} {# when field has no value: count_field_element_3 = 0; #}
Maybe my question is not very clear, let me explain more as below: The purpose of this question is to check if paragraphs field (not other field types) has a value. When a field value is input and saved, node page will show the field and its value; when no field value is input and saved, node page will NOT show the field (including the div element).
{% set count_field_element = node.field_paragraphs|length %} {{ count_field_element }}
count_field_element is 1 for below: 
count_field_element is 0 for below(removing all form items of paragraphs in node form): 
In short, up till now, I still NOT figure out a way to check if a paragraphs field has a value, node page will show paragraphs field empty only when removing all form items of paragraphs in node form.