-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
[feature] Add "embed" block #488
Comments
What do you mean by "without an extra file"? Unless I'm misinterpreting something from the docs you linked, then you still need all your (partial) templates in separate files. So with I like it and can personally see many uses. Just want to make sure I didn't miss anything. |
I'm open to it in principle as long as it doesn't add too much complexity in the code generator; if it can reuse most of the existing infrastructure for extends/block, I'm fine with adding another interface to it. |
"without an extra file" means, that you don't need an extra file to extend the base template. Normally when you want to extend something, you use 3 files. For the parent and child template, and the template, where you include it. With this embed you only have 2. The parent and the including template which is doing what the child template is doing but inside of the embed. I'm just describing it badly. The linked documentation however exaclty describes, what I'm trying to explain. |
I'm still not sure I understand the "without an extra file", maybe I'm tired, I don't know. :) If we go with your original example, you have a Even if we're talking about complex template inheritance. Say you have a I'm clearly missing something. :) Regardless, I still think |
Okay then; here the use case I had: Building a But much more pleasing (for page-unique modals at least) to just embed the I built another modal with a macro and just pass a different id so that I can idetify it through JS. But in this case it was possible because I used the same body on all pages. Hope this can clarify it by now :D |
Yeah, I can follow that use case, I had something similar in mind. But I still don't entirely understand how it would decrease the files needed? :) Ultimately isn't |
Before I try to review your PR, I'd like to see a fully worked example of the template files you think you need without this feature and the templates you'd need if this feature was available, to make sure I understand what you're trying to achieve. |
Sure, I will put you together an example, I hope it's fine when I omit any JavaScript and CSS parts from it |
Sure! It doesn't need to be detailed, minimalism is probably best here though a little meaning can help understand the context. |
It took a while and I only have a broken example, but it at least shows off what I am (or was) trying to achieve. I'm not sure what exactly is wrong with my part of the code, I cannot find the error message, that is printed but I had it before and fixed it somehow. But I also saw, that it seems to be impossible to |
So after some checking I fixed one issue on my side and according to the code and the With the extends removed from the included templates however I get a "no entry found for key". If I read the code correctly this is because includes, that are inside a |
Having an "embed" block like twig has it, which is basically an "extend" but without an extra file, would be an awesome addition to the library I think.
Is it in the current implementiation possible to get something like this working (or is there maybe even something like this already)?
This would be very useful if a macro is just to small or you want to get more markup replaced in a general structure (like a modal).
The text was updated successfully, but these errors were encountered: