If you have an attribute of the "layout" datatype and leave it empty, ez_is_field_empty will always return false (implying it's not empty).
A dump of the content will show the following for the layout attribute
- Create a new class and add a "test_me" layout attribute
- Make an override template for that class and add the following code to it
- Create a content of that class and try to open it in the frontend. You will see the "This is not empty" header displayed.
If you try to render the layout field
You will get the following exception
An exception has been thrown during the rendering of a template ("Could not find an ezpage zone definition block for given layout ''") in "EzPublishCoreBundle::content_fields.html.twig".