{% extends ['@nucleus/module-chrome/' ~ style ~ '.html.twig', '@nucleus/module-chrome/gantry.html.twig'] %}

{% set id = segment.id ?: segment.type ~ '-' ~ rand(1000, 9999) %}
{% set chrome = segment.chrome %}

{% block title %}
    {% if segment.chrome.display_title %}{{ segment.title }}{% endif %}
{% endblock %}

{% block module %}
    {% if segment.type in ['particle', 'spacer'] %}
        {% set item = {id: position.key ? position.key ~ '-module-' ~ id : id, type: segment.type, subtype: segment.options.type, attributes: segment.options.attributes} %}
        {% set attribs = {inContent: inContent}|merge(ajax ? {ajax: ajax} : {}) %}
        {{ gantry.theme.renderContent(item, attribs)|raw }}
    {% else %}
        {% include [
        '@nucleus/content/' ~ segment.type ~ '/' ~ segment.options.type|default('default') ~ '.html.twig',
        '@nucleus/content/' ~ segment.type ~ '.html.twig',
        '@nucleus/content/unknown.html.twig']
        with { segment: {id: id, type: segment.type, subtype: segment.options.type, options: segment.options, attributes: segment.options.attributes }} %}
    {% endif %}
{% endblock %}
