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

Request for improvements: Liquid slot tag to render contents in predefined places #1854

Open
ConduciveMammal opened this issue Nov 18, 2024 · 1 comment

Comments

@ConduciveMammal
Copy link

Other platforms and frameworks have the ability to place code within a placeholder element somewhere else on the theme.

October CMS does this using {% placeholder xyz %}, Astro does this using <slot name="xyz" />.

It makes sense for Shopify to allow this due to the hugely dynamic nature of sections and blocks.

Right now, to include dynamic styles on a section, I need to write them within the section file, which means the style and script definitions are littered everywhere.

A Liquid slot tag would allow developers to better optimise their themes by allowing specific blocks of code to go in specific areas.

Examples

Styles

slider.liquid

{%- if section.blocks.size > 0 %}
  {{ 'slider.css' | asset_url | preload_tag: as: 'style', slot: 'head_preloads' }}

  <section class="shopify-section" id="shopify-section-slider">
    {% slot head_styles %}
      <style>
        .slide {
          background-color: {{ section.settings.slide_background_color }};
        }
      </style>
    {% endslot %}
  </section>
{%- endif -%}

<head>
  ... head things
  {{ slots.head_preloads }}

  {{ slots.head_styles }}
</head>
@isaacbowen
Copy link

yield? content_for? a couple patterns from rails-land that feel related

@benjaminsehl benjaminsehl changed the title Request for suggestions: Liquid slot tag to render contents in predefined places Request for improvements: Liquid slot tag to render contents in predefined places Dec 11, 2024
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