Use {% render %}, vars, assets , or other inside {% schema %} to make repeated settings modular, reduce duplicated settings code. #42
Replies: 5 comments 8 replies
-
|
Lots of great suggestions, there are so many ways to approach the subject, it's crazy ahah Definitely agree more when you're saying the shared schema problem will explode with theme-blocks ! |
Beta Was this translation helpful? Give feedback.
-
|
Hey @PaulNewton, I do like this but I have some reservations about the Liquid and JSON infusion. I tend to lean on the side of keeping Liquid within markup and is personal preference that stems partly from the challenges I've faced taming lexers in Æsthetic to handle Liquid structures within JavaScript, CSS and JSON. But, I digress... AFAIK Shopify processes That said, I believe many experienced developers would welcome the ability to dynamically inject schema on the fly as per code samples. Your suggestion here would certainly help reduce repetition and promote a more DRY approach overall. However, we should consider that this level of extensibility might only benefit a small minority of developers who are well-versed in the intricacies of Shopify theme dev. Maybe I'm over analyzing here, but it's easy to forget that many developers working on Shopify themes may not approach problems with such advanced techniques in mind (IYKWIM), but I'd be curious on the thoughts of other devs. Regarding the shared schema tacticIt went through several iterations before arriving at the version I described in #15 (reply in thread). I was fortunate to receive valuable feedback from several talented developers, including @TeamDijon, during the initial phases. The goal was to make shared schema feel native and avoid overly complex logic. I believe the current implementation achieves this, and Shopify could potentially replicate that functionality with relative ease, given that it mimics behavior already present in the theme architecture. As you pointed out, the current approach does require a build step, which can be a barrier to adoption for a lot of developers, and I'm yet to make things easy for devs in Syncify. It's worth noting, however, that Syncify has been designed as a potential replacement for the Shopify CLI in theme development, with the foundations already in place to achieve its intended purpose. FWIW, I'm planning to resume active development on the project in coming weeks. Once it's out of beta and viable for real-world usage, I'd love to have someone with your expertise provide insights. I've really enjoyed reading your perspectives and suggestions in this repo lately. |
Beta Was this translation helpful? Give feedback.
-
Meta fix: native build systemFor JSON authorship having full liquid support in {% schema %} tags is sanity measure, addressing several problems in developering, customizing or managing shopify themes. A native build system is such a departure that in practice if a single merchants theme needs a build system that's just an indication that a store should be using hydrogen. |
Beta Was this translation helpful? Give feedback.
-
If nothing is done...I wouldn't be shocked if some are clinging to the idea of AI|LLM fixing such gap issues so once again everyone can ignore that first-party tooling is not first-class while ANI-assistants spout out time wasting nonsense. And any gold rush or golden era in third party tools shouldn't be where the bare minimum in a first day experience, Meanwhile if nothing is done because it's too hard or it's kicked down the road due to "technical limitations" that means in terms of authorship efficiency the code duplication in the nesting-blocks architecture will be yet another new larger gap between have and have-nots |
Beta Was this translation helpful? Give feedback.
-
|
Another idea for implemention here: #15 (reply in thread) Main difference is not to use the render tag but to extend the schema tag to work like it. The nice part of keeping them separate is that the schema tag references files in the Also, in this implementation, existing liquid syntax is retained making adoption of the new syntax very easy. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be better if we had some way to reference a single file to be reused in {% schema %}'s
Using {% render %}, variables or assets filters? , or some other method inside {% schema %} to consolidate code, making repeated settings modular and composable without needing external tooling.
Also see discussion here for "Shared schema capabilities"
Settings have always had a high amount of duplicated code which has made it important when developing themes to also have to create a build process or tools to help share a single source of code for schema's across multiple files.
But that's if you know how to make build tools or have the time to do so.
Then aftermarket developers wont have any of the build process used to make a theme so changes to settings can mean editing every single file by hand that needs a specific setting changed or added; when find+replace aren't up to the job; which can also be an error prone process editing a machine format even it is human readable.
And that was for sections, this problem is going to 💥explode💥 when extended to theme-blocks settings and presets.
It would be better if we could just get rid of this extra phase of editing.
For example if a merchant wanted to add a custom icon to the reference theme at least three areas have to be edited.
The {% schema %}'s in two block files and a snippet to insert the svg code.
https://github.com/Shopify/reference-theme/blob/main/blocks/icon.liquid
https://github.com/Shopify/reference-theme/blob/main/blocks/link.liquid
https://github.com/Shopify/reference-theme/blob/main/snippets/icon.liquid
In such customizations the merchant then also needs to add liquid-logic to the files to consume the settings.
It would be better if we had some way to reference a single file to reuse code in {% schema %}'s using existing concepts such as:
Hypothetical example of {% render %} inside {% schema %} :
{% schema %} { "name": "Button", "tag": null, "settings": [ { "type": "url", "id": "link", "label": "Link" }, {% render 'icon-schema' %}, {% render 'icon-schema' , default: 'none' %} ] } {% endschema %}with icon-schema containing the entire
iconsetting in the icon blockHypothetical example of variables made outside the {% schema %} :
{% capture schema_image_picker %} { "type": "image_picker", "id": "image_upload", "label": "Custom icon" } {% render 'icon-schema' %} {% endcapture %} {% schema %} { "name": "Button", "tag": null, "settings": [ { "type": "url", "id": "link", "label": "Link" }, {{ schema_image_picker }} ] } {% endschema %}Hypothetical example of an asset filter for json assets inside the blocks folder {% schema %} :
{% schema %} { "name": "Button", "tag": null, "settings": [ { "type": "url", "id": "link", "label": "Link" }, {{ 'icon-schema.json' | block_asset }}, {{ 'icon-schema.json' | block_schema }} ] } {% endschema %}Hypothetical example included JSON can be partial it doesn't have to be a full setting or schema.
Or course the rendered code still must always results in valid json so what is actually in the snippet doesn't have to be a full schema.
Meaning this this would work as well just filling partial of a setting instead of the entirety:
{% capture schema_image_picker_label %} "label": "Custom icon"{% endcapture %} {% schema %} { "name": "Button", "tag": null, "settings": [ { "type": "url", "id": "link", "label": "Link" }, { "type": "image_picker", "id": "image_upload", {{ schema_image_picker_label }} } ] } {% endschema %}Or other?
Meanwhile something more strict requiring the included files to contain an entire setting or preset would probably require a new tag , or new setting types don't use liquid and are still only JSON to reference the files.
I'm not a fan of yet another tag piling on liquid's growing vocab, but I'm a huge fan of something that would wipe out thousands of lines code in themes and reduce the complexity of third-party build tooling; though may add complexity to syntax-highlighting womp womp
Hypothetical example of a new setting properties to reference settings files for inclusion.
{% schema %} {% section_schema 'shaped-divider-schema' %} {% block_schema 'badges-schema' %} {% setting 'badges-schema' %} "etc": "etc etc" {% endschema %}Example of a $ref property by panoply
See @panoply's discussion #15 (reply in thread)
What new tag names or setting-property names would be ,or there exact syntax would be something to hash out.
Preferable if it's syntax has some similarity to some mainstream system familiar to most devs; can't think of any off top of my head.
I guess the blocker for this has probably been something like the visual-theme-editor's statically parsing the JSON
Beta Was this translation helpful? Give feedback.
All reactions