liquid icon indicating copy to clipboard operation
liquid copied to clipboard

implementation/tests of the template inheritance mechanism

Open did opened this issue 10 years ago • 11 comments

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!

did avatar Apr 08 '14 22:04 did

cc @Shopify/liquid

fw42 avatar Apr 09 '14 01:04 fw42

@tylerball, can you check it out and see if this is close to what you had in mind?

fw42 avatar Apr 09 '14 01:04 fw42

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!

did avatar Apr 09 '14 09:04 did

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?

tobi avatar Apr 09 '14 13:04 tobi

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?

did avatar Apr 09 '14 14:04 did

@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?

did avatar Apr 10 '14 08:04 did

btw @fw42 & @tylerball, it works now with liquid 3.0.

did avatar Jan 18 '15 15:01 did

@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?

jeroenvisser101 avatar Jun 09 '16 12:06 jeroenvisser101

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 avatar Jun 09 '16 20:06 did

@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.

jeroenvisser101 avatar Jun 10 '16 07:06 jeroenvisser101

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 :)

maogongzi avatar Oct 26 '21 03:10 maogongzi