Modular Page part does not render when content empty

I have a problem integrating https://github.com/variar/grav-plugin-unitegallery in my twig templates of a theme inheriting from Quark. The pages are generated by converting an old TYPO3 site and have lots of galleries on part of the pages.

So I added an empty block named galleries to partials/base.html.twig and modified default.html.twig in this way:

{% extends 'partials/base.html.twig' %}
{% macro pageLinkName(text) %}{{ text|lower|replace({' ':'_'}) }}{% endmacro %}

{% block content %}
    {{ page.content }}
{% endblock %}

{% block galleries %}
    <div class="galleries">
    {% for module in page.collection('galleries') if module.template == 'modular/gallery' %}
        <div id="{{ _self.pageLinkName(module.menu) }}"></div>
        {{ module.content }}
    {% endfor %}
    </div>
{% endblock %}

modular/gallery.html.twig is

{% set grid_size = theme_var('grid-size') %}
{% set columns = page.header.class == 'small' ? 'col-3 col-md-4 col-sm-6' : 'col-4 col-md-6 col-sm-12'  %}

{% set gallery_id = (page.header.unitegallery.gallery_id ?: page.slug|ltrim('_')) %}
{% set gallery_theme = page.parent.header.unitegallery.gallery_theme ?: 'tiles' %}
{% set gallery_options = { 'gallery_theme': gallery_theme } %}

{{ page.content }}

<div class="gallery-container {{ page.header.class }}">
  {{ unite_gallery(page.media.images, gallery_options|json_encode, gallery_id) }}
</div>

The problem is in the {{ module.content }} call in default.html.twig: If the markdown of the modular gallery page is not empty every thing works as expected. If the markdown is empty, only with a frontmatter in the md file, nothing of the modular template is rendered and even the debugger does not show up on the displayed page. With no error in logs, console and no debugger I am not sure what happened. If I add just one line of content everything works as expected.

The problem is not a gallery problem, I know how to handle them, and the problem is the same if I omit the gallery call and just render some dummy html.

Why is the subpage not rendered if it has an empty content? Because of the missing debugger output I think of a bug, not of a problem of misunderstanding twig rendering and caching. Am I right?

What must I do to fix this? Should I create an issue?

Additional information: In the frontmatter of the containing page I have

galleries:
  items: '@self.modular'
unitegallery:
  gallery_theme: tiles

Newest grav 1.4.7

Update 22.07.2018:

No errors was not true, i looked into a another apache log, not the right one. Error there was:

[Sun Jul 22 09:59:00.787786 2018] [:error] [pid 3152] [client 84.57.9.254:4906] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/system/src/Grav/Common/Plugin.php on line 265
[Sun Jul 22 09:59:00.788029 2018] [:error] [pid 3152] [client 84.57.9.254:4906] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/vendor/monolog/monolog/src/Monolog/Logger.php on line 416

After increasing memory to 256 MB still errors, but in other routines:

[Sun Jul 22 10:06:23.521845 2018] [:error] [pid 3695] [client 84.57.9.254:5300] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/vendor/symfony/event-dispatcher/Event Dispatcher.php on line 184
[Sun Jul 22 10:06:23.522013 2018] [:error] [pid 3695] [client 84.57.9.254:5300] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /var/www/domains/saint-josse-europe.eu/grav/vendor/filp/whoops/src/Whoops/Run.php 

Think it is an infinite loop somehow. Will look deeper.

Hello @tremel !
I remember having seen something similar on the GRAV’ Slack, where people were talking about this kind of PHP memorry error, and about images generating.

There is also some archives on this forum : Responsive images

Try to considere these things :

  1. Images generation in some of the pages called, results in PHP memory saturation (even if the trigger is a page in wich there is no image).
  2. Calling a markdown with empty content, in the context of your complex tempate, results in a bug. You could workaround by setting a dummy text, and just hidding it (as you tried yourself).
  3. Your template is too complex, in some way. There is a kind of loop in the data process, or anything performing the aforementioned saturation.

Hello @Romarain,

Thank you for your answer. At the moment I think your second point is the most probable and filed an issue.

I think it hasn’t to do with the images, since just rendering a single paragraph without the gallery call results in the same failure. I don’t think my templates are too complex. Either my kind of using twig is wrong or strange, or it is a bug.

Andy Miller promised to investigate in this issue.

Dieter