-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Rationale behind blocks only at top level #85
Comments
It's basically been there from when I started on inheritance to make things easier, and no one has asked for it until now. I think with the current design of how inheritance works, these can be accomodated, but I'll have to dig into it a little (unless you want to take a look, I can provide some guidance where to look in the code). |
Thanks for the quick response!
Unfortunately, it seems like a large feature to look into adding when I'm completely unfamiliar with the codebase, especially if even you would need to dig into it, so I'd rather leave it to the professionals. 😃 |
Master now implements deep inheritance and the |
Ooooh for the first time ever my askama branch compiles! You're the best! |
Note that you also no longer need the |
I have a base template in a Flask app that I'm porting that has something like the following in the <head>: {% if page.no_index %}
<meta name="robots" content="noindex,nofollow">
{%- else %}
{%- block meta_x %}{% endblock %}
{%- endif %} Various other templates then implement the |
Yeah, I think that limitation might still be in place. I guess I was too lazy to write the more generic code that can walk the entire AST, and there's some argument that doing so will incur more compile-time costs. Probably should just fix it anyway. Would you mind filing a new issue about it? (Bonus points if you also want to try your hand at a PR. 😄 The relevant code is here: https://github.com/djc/askama/blob/master/askama_shared/src/heritage.rs#L45.) |
Hello! I recently discovered askama, and I'm very excited about moving to it over Tera. I don't fully understand everything right now, but in trying to migrate, I discovered a confusing error.
I read that blocks can't be in loops, and that makes sense. However, I'm slightly confused as to why my templates, which include no blocks in loops, etc. aren't compiling. I get
blocks ('header') are only allowed at the top level
.header
is inside ofbody
, but I really don't understand why this isn't allowed. In fact, it's extremely useful to be able to provide bits inside of larger blocks that can be overwritten.In addition, blocks lack the ability to do something similar to
{{ super() }}
from Tera, which lets you include the block's content instead of overwriting it, which is extremely useful. (Unless you can do so by doing{{ _parent }}
. I don't really understand_parent
, to be honest. My base template frames have no context, so having to make empty structs for them is confusing.)What's the rationale behind denying this? It's a gigantic blocker for me, and I really want to use askama.
The text was updated successfully, but these errors were encountered: