Prevent empty layout snippet to be rendered

Hello,
I am new to kirby. On my homepage I use blocks with layout:

blocks:
        type: fields
        fields:
          homecontent:
            label: mehr Inhalt
            type: layout
            layouts:
              - "1/1"
              - "1/2, 1/2"
              - "1/3, 1/3, 1/3"
              - "1/3, 2/3"
              - "2/3, 1/3"
            fieldsets:
              - heading
              - text
              - list
              - image
              - download

If I add no layout, I get en error: JSON String invalid
I can solve this by adding
homecontent: [] to 01_home.txt, but if I use the panel the fiield is empty: homecontent:
I tried to fetch this in the template:

<?php if( $page->homecontent() ): ?>
    <?php snippet('layouts', ['field' => $page->homecontent()]) ?>
  <?php endif ?>
```, but that does not work.
How can I prevent that the empty field is rendered?

Hi and welcome to the Kirby forum!

Your if statement should read:

<?php if ($page->homecontent()->isNotEmpty()): ?>
    <?php snippet('layouts', ['field' => $page->homecontent()]) ?>
  <?php endif ?>

Wow, that is fast!
Thank you!