-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Plan to implement {{block.super}} #38
Comments
One of the primary goals of liquidjs is to keep compatible with the ruby version. It will be a great feature, but could you answer the following questions before we introduce this feature to the core:
|
hi @harttle , thanks for pointing out that I should dig into Liquid docs first, I looked through their official Github repo, wiki and also websites and didn't find any sign indicating they will implement it now or later, yet I did find this long period issue which is still not fully resolved since it opened years ago, in which there is a discussion whether to implement the Django-style compatible inheritance system, but since there isn't any further progress been made, there isn't any other place I could find more information about it for now, so the answers are:
and back to the issue itself, I think since we've already got 'layout' and 'block' tags, it would be nice to have block.super implemented as well :) |
If I understand correctly,
Is this inheritance direction (child -> parent via the |
Closing since not documented by shopify liquid, and not clear how it works. If there's a specific document or a clear requirement to this feature, I'll reopen this issue. |
Hello @harttle! 👋 I was hunting around to see if this feature had already been mentioned and ended up here. I do wonder if this is something that may be reconsidered (AFAICT it still does not exist in Ruby Liquid). However, I do think the value of having something like As it exists in Django,
(This also exists in the Jinja2-inspired Nunjucks as the What I've commonly used this to do is append or prepend markup that has been defined in a parent layout's block without overriding it. A good example of this with CSS linking: Parent layout: base.html {% block css %}
<link href="base.css" rel="stylesheet">
{% endblock css %} Child page: index.html {% layout "base.html" %}
{% block css %}
{{ block.super }}
<link href="extra.css" rel="stylesheet">
{% endblock css %} Output <link href="base.css" rel="stylesheet">
<link href="extra.css" rel="stylesheet"> What's nice about this is you can define some defaults or base values in a block that the inheriting template can choose to overwrite or add to as needed. As provided in the two scenarios I am familiar with (Django and Nunjucks) there is never the intention that the parent and child pages' scopes combine or interact in any way — either the as-rendered contents of the parent page's block is rendered as-is where I believe this is can be very helpful for defining blocks in a parent layout with smart defaults that a child page can augment instead of completely overwrite (or as it often happens, content that appeared in the parent's block gets copy-pasted to the child page's block because it needed the exact same content + an extra line on the end). |
# [9.20.0](v9.19.0...v9.20.0) (2021-01-23) ### Features * support `{{block.super}}`, see [#38](#38) ([a3af44d](a3af44d))
Now supported on @9.20.0, thank you guys. |
Hello, thanks for your hard works! currently I'm using nunjucks in our frontend project(mock server with express), but I have a plan to migrate to liquidjs instead, because our Backend is also using liquid, some of their syntax differencies bother me a lot because each time I have to manually adjust nunjucks templates to standard liquid syntax before sending them to backend developers, I have searched a lot and finally found liquidjs, really amazing, but I really miss the
{{block.super}}
syntax, since we have already supported "block", I would like to know do we have some plan to implement it as well? It would be a huge benefit and I think some others might also have the same question as me :)The text was updated successfully, but these errors were encountered: