Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Formatter] #1040

Open
3 tasks done
tanc opened this issue Nov 26, 2024 · 0 comments
Open
3 tasks done

[BUG] [Formatter] #1040

tanc opened this issue Nov 26, 2024 · 0 comments
Labels
🦠 bug Something isn't working 🧽 formatter

Comments

@tanc
Copy link

tanc commented Nov 26, 2024

Very similar to #370 except for custom blocks and include.

System Info

  • OS: Ubuntu 22.04.5 LTS
  • Python Version: Python 3.10.12
  • djLint Version: 1.36.1
  • template language: Twig

Issue

When using custom blocks story and stories in Twig templates, the indentation of with object/array is collapsed. It also happens within Twig's include tag which can also take a with parameter.

How To Reproduce

Using this .djlintrc file:

{
    "custom_blocks": "story,stories",
    "indent": "2",
    "max_blank_lines": 2,
    "profile": "nunjucks"
}

and operating on this template:

{# Define the footer stories #}

{% stories footer with { title: 'Layout/Footer' } %}

  {% story default with {
    name: 'Footer',
    parameters: {
      docs: {
        description: {
          story: 'A footer is a container for various optional components.',
        },
      },
    },
    args: {
      copyright_notice: '© 2024',
      menu_items_housekeeping: [
        {
          title: 'Accessibility',
          url: 'internal:/'
        },
        {
          title: 'Cookies',
          url: 'internal:/'
        },
        {
          title: 'Jobs',
          url: 'internal:/search'
        },
        {
          title: 'Our Test',
          url: 'internal:/'
        },
        {
          title: 'Terms and privacy',
          url: 'internal:/'
        }
      ]
    },
    argTypes: {
      copyright_notice: {
        name: '© 2024',
        type: 'string',
      },
      menu_items_housekeeping: {
        name: 'Housekeeping Menu items',
        type: 'object',
        defaultValue: [
          {
            title: 'Accessibility',
            url: 'internal:/'
          },
          {
            title: 'Cookies',
            url: 'internal:/'
          },
          {
            title: 'Jobs',
            url: 'internal:/search'
          },
          {
            title: 'Our Test',
            url: 'internal:/'
          },
          {
            title: 'Terms and privacy',
            url: 'internal:/'
          }
        ]
      }
    }
  } %}

    {% set footer_region %}
      {% include "@test/stories/03-layout/footer/regions/region-footer.twig" %}
    {% endset %}

    {% set housekeeping_region %}
      {% include "@test/stories/03-layout/footer/regions/region-housekeeping.twig" %}
    {% endset %}

    {#
      The page variable is passed to the footer template as so it can render
      the footer region.
    #}
    {% set page = {
        housekeeping: housekeeping_region,
        footer: footer_region,
      }
    %}

    <div class="storybook-html">
      {% include '@test/layout/footer.html.twig' with {
        page: page,
        has_housekeeping: true,
        has_footer: true,
      } %}
    </div>
  {% endstory %}

{% endstories %}

The result is:

{# Define the footer stories #}

{% stories footer with { title: 'Layout/Footer' } %}

  {% story default with {
    name: 'Footer',
    parameters: {
    docs: {
    description: {
    story: 'A footer is a container for various optional components.',
    },
    },
    },
    args: {
    copyright_notice: '© 2024',
    menu_items_housekeeping: [
    {
    title: 'Accessibility',
    url: 'internal:/'
    },
    {
    title: 'Cookies',
    url: 'internal:/'
    },
    {
    title: 'Jobs',
    url: 'internal:/search'
    },
    {
    title: 'Our Test',
    url: 'internal:/'
    },
    {
    title: 'Terms and privacy',
    url: 'internal:/'
    }
    ]
    },
    argTypes: {
    copyright_notice: {
    name: '© 2024',
    type: 'string',
    },
    menu_items_housekeeping: {
    name: 'Housekeeping Menu items',
    type: 'object',
    defaultValue: [
    {
    title: 'Accessibility',
    url: 'internal:/'
    },
    {
    title: 'Cookies',
    url: 'internal:/'
    },
    {
    title: 'Jobs',
    url: 'internal:/search'
    },
    {
    title: 'Our Test',
    url: 'internal:/'
    },
    {
    title: 'Terms and privacy',
    url: 'internal:/'
    }
    ]
    }
    }
    } %}

    {% set footer_region %}
      {% include "@test/stories/03-layout/footer/regions/region-footer.twig" %}
    {% endset %}

    {% set housekeeping_region %}
      {% include "@test/stories/03-layout/footer/regions/region-housekeeping.twig" %}
    {% endset %}

    {#
      The page variable is passed to the footer template as so it can render
      the footer region.
    #}
    {% set page = {
          housekeeping: housekeeping_region,
          footer: footer_region,
        } %}

  <div class="storybook-html">
    {% include '@test/layout/footer.html.twig' with {
    page: page,
    has_housekeeping: true,
    has_footer: true,
    } %}
  </div>
{% endstory %}

{% endstories %}
@tanc tanc added 🦠 bug Something isn't working 🧽 formatter labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦠 bug Something isn't working 🧽 formatter
Projects
None yet
Development

No branches or pull requests

1 participant