liquid
liquid copied to clipboard
implementation/tests of the template inheritance mechanism
hi @fw42 & @tylerball, Based on the conversation here (https://github.com/Shopify/liquid/pull/264), this is my implementation of template inheritance, similar to what offers Django (https://docs.djangoproject.com/en/dev/topics/templates/). Code mainly extracted from the LocomotiveCMS fork of Liquid. Feel free to comment and ask me questions. Thanks!
cc @Shopify/liquid
@tylerball, can you check it out and see if this is close to what you had in mind?
hi @fw42, I pushed a new version of my PR. It reflects the modifications you brought up in your comments. Let me know if you have other comments / questions. Thanks!
This is a large departure from the current way to use liquid. It's implemented well but it will divide liquid users into two camps: The more traditional composition and the Django style block approach. Should this perhaps be an addon gem?
I understand your concern about this feature, knowing that this might have "consequences" for your Shopify customers. That said, nobody is forced to use the inheritance template. Going further, making it as an add-on would be a good compromise. Would it be the first add-on for Liquid?
@tobi, is that possible this add-on becomes an "official" gem in a sense its sources would be stored in your github organization so that people can contribute / maintain it in more official way than it's actually. Because I've got this code for a couple of years in my forked version of Liquid but it was kind of hidden finally. What are your thoughts?
btw @fw42 & @tylerball, it works now with liquid 3.0.
@did I've tried to port changes from 7e4eacd to the gem, but it doesn't seem to work. Instead, the tests throw Liquid::SyntaxError: Liquid syntax error: 'extends' tag was never closed
, I assume it expects a {% endextends %}
(which shouldn't be required). Any idea how to proceed?
hey @jeroenvisser101, I think they changed a couple of stuff in their API. The liquid version we're using for locomotivecms (http://www.locomotivecms.com) can be found here: https://github.com/locomotivecms/liquid. The last commit from the original master branch was from Jan 24, 2015. Hope it helps...
@did thanks! I'll have a look at that for sure. My best outcome would be to get it working with the 'original' version of liquid, and to get it working with the master branch (there's some things that changed there, options doesn't seem to be writable anymore, but I'll have to investigate more)
I'll let you know when I've got something solid. I don't think it'll be able to be merged into locomotivecms's fork, since it might not work with the liquid fork, but let's have a look when/if I get this to work.
Do we have a plan to merge it at some point? Since it's coming to the end of 2021 and roughly 7 years passed, and this feature really helps to facilitate the works to maintain a bunch of templates that people don't need to copy and paste again and again those same snippets everywhere :)