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

content_for_layout rendered before section group #476

Open
stijns96 opened this issue Aug 26, 2024 · 1 comment
Open

content_for_layout rendered before section group #476

stijns96 opened this issue Aug 26, 2024 · 1 comment

Comments

@stijns96
Copy link
Contributor

Describe the bug
content_for_layout is rendered before the section group if you do a check for something inside. In the source below you can see that I only check for something in the content_for_layout, but somehow it's also put above the actual group in the theme editor. In the frontend itself it renders at the right position

Image

Source

{%- liquid
  # Automatically add microdata to the HTML element if the content contains the section with the class 'section--faq-sections'
  if content_for_layout contains 'section--faq-sections'
    assign microdata = 'itemscope itemtype="https://schema.org/FAQPage"'
  endif
-%}

{%- sections 'header-group' %}

<main {{ microdata }}>
  {{ content_for_layout }}
</main>

Expected behaviour
Render the content_for_layout at the right position in the theme editor and not where I've added an if statement.

Actual behaviour
It renders the content_for_layout in the theme editor at the position where the if statement is placed.

Debugging information

  • OS [e.g. Windows, Mac, Linux]
  • OS Version
  • Theme Check Version [e.g. 0.1.0]

Additional context
Add any other context about the problem here.

@charlespwd
Copy link
Contributor

Unfortunately, the ruby code that defines the order doesn't have the same luxury we have in theme-tools. They don't have a HTML+Liquid AST to play with. I suspect they use some form of regex to find the order.

This can be solved by rewriting the section like this:

{%- sections 'header-group' %}

{%- liquid
  # Automatically add microdata to the HTML element if the content contains the section with the class 'section--faq-sections'
  if content_for_layout contains 'section--faq-sections'
    assign microdata = 'itemscope itemtype="https://schema.org/FAQPage"'
  endif
-%}

<main {{ microdata }}>
  {{ content_for_layout }}
</main>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants