I know how to check if a field is empty in a twig template (example node--lorem.html.twig):
{% if node.field_lorem.value is not empty %}
<p>not empty</p>
{% else %}
<p>empty</p>
{% endif %}
I would like to check if a field is not empty inside a paragraph twig template (example paragraph--lorem.html.twig
). But this doesn't work :
{% if content.field_lorem.value is not empty %}
or
{% if node.field_lorem.value is not empty %}
I can display this field value like this :
{{ content.field_lorem }}
node
withparagraph
{% if paragraph.field_lorem.value %}
, notnode
. Notcontent
.content
contains only fields that have been added to the display of your entity.