-
Notifications
You must be signed in to change notification settings - Fork 22
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
cannot use base.html and subdir/base.html in inheritance chain #89
Comments
Further testing... I was messing around with stuff and i have this working:
not working:
ALSO not working:
I had a similar thing happening when implementing a website using builtin golang templates. I was caching the templates in a hashmap by the filename, and it was only considering the base name , not the directory, so a later template with the same name but in a sub-dir would overwrite the template cache of a template with the same name not in a sub-dir (or in a diff sub-dir etc.) |
Thanks for reporting. I'll take a look. |
Yes. Problem is current store doesn't look at file system directories as part of template names, behaves kind of a global database of template filenames, regardless of subdirectories. And so extends "base.html" in |
Give priority to template store search paths over current path See Github issue #89
I've pushed a change you can try. It is not a fix, only changes the priority when looking for templates in file system. But could help with this. |
I'm going to try to implement relative includes now. I think they could be a simple to implement solution to this. |
Makes it possible to use relative pathnames in extends. For example: {% extends "../base.html" %} See Github issue #89
I've implemented relative extends, so you can point directly to your templates using "../base.html" in |
Thanks for looking at this! |
I found when I implement a template cache that it is easier to just include the full path as the key instead of just the base name. I think this also logically makes sense because base.html is completely a different thing than subdir/base.html. And that's the Django idiom. But I haven't looked at what you've done so, take that with a grain of salt until I do. Thanks again! |
Ok. I'll take a look at the cache too.
El mar, 2 de ene de 2024, 14:36, Paul Wisehart ***@***.***>
escribió:
… I found when I implement a template cache that it is easier to just
include the full path as the key instead of just the base name. I think
this also logically makes sense because base.html is completely a different
thing than subdir/base.html. And that's the Django idiom.
But I haven't looked at what you've done so, take that with a grain of
salt until I do.
Thanks again!
—
Reply to this email directly, view it on GitHub
<#89 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADKPDQJ6BHIYFDIMG6B3ELYMRASRAVCNFSM6AAAAABBHXGIYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGMZTIOBTHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
; compiling file "/disk1/home/wise/quicklisp/local-projects/djula/src/template-store.lisp" (written 02 JAN 2024 03:40:0 ; compilation aborted after 0:00:00.001 |
I got that putting a checkout of the latest djula repo into my ~/quicklisp/local-projects/ directory. |
There was a problem with dependencies. Can you try again? Apologies. |
Thanks!, This is worse. For this example my sub-app is "todo": Previous this works: Now that doesn't work: debugger invoked on a SIMPLE-ERROR in thread Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL. restarts (invokable by number or by possibly-abbreviated name): ((:METHOD DJULA:FIND-TEMPLATE (DJULA:FILESYSTEM-TEMPLATE-STORE T)) #<DJULA:FILESYSTEM-TEMPLATE-STORE {1005D195A3}> "todo/index.html" T) [fast-method] Did you make sub-directory paths not work at all? I think it's more idiomatic to django (and jinja) to be able to organize with directories even if you can't reuse the base.html filename. |
Ok. I'll revert or come up with a solution.
El dom, 7 de ene de 2024, 19:12, Paul Wisehart ***@***.***>
escribió:
… Thanks!,
This is worse.
For this example my sub-app is "todo":
Previous this works:
base.html
todo/base_todo.html <-- this extends base.html with {% extends
"todo/base_todo.html" %}
Now that doesn't work:
debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {10013A00A3}>:
No current path for relative pathname: "todo/index.html"
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
((:METHOD DJULA:FIND-TEMPLATE (DJULA:FILESYSTEM-TEMPLATE-STORE T))
#<DJULA:FILESYSTEM-TEMPLATE-STORE {1005D195A3}> "todo/index.html" T)
[fast-method]
source: (ERROR "No current path for relative pathname: ~s" NAME)
0]
Did you make sub-directory paths not work at all?
I think it's more idiomatic to django (and jinja) to be able to organize
with directories even if you can't reuse the base.html filename.
—
Reply to this email directly, view it on GitHub
<#89 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADKPDSM6EWHWMOJVHP2UQTYNMMWTAVCNFSM6AAAAABBHXGIYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGE4TEMJTGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
This should work again. But I need to take time to test it. |
I've added some tests. Seems to be in good shape to me now. |
Hi!,
Djula is great!
I am a django template user from way back.
I have just debugged a weird case with a common inheritance pattern.
I have the bottom "base.html".
In a subdirectory I want to extend it with common features to some module.
So I have "search/base.html" extends "base.html".
And then everything in search/ will extend the local search/base.html.
Pretty typical pattern, i almost make it more confusing explaining it.
Ok with that above pattern I get:
fatal error encountered in SBCL pid 55444 pthread 0x1ac6c06fc30:
Control stack exhausted while pseudo-atomic, fault: 0x1ac40d17fa0, PC: 0x1ac6c066f86
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb>
If I change search/base.html to search/base_search.html (or whatever) it works.
So something with the common base name is causing some loop ? obviously i have no idea :)
Anyways the workaround works but i did narrow it down enough to repro in case this interests you.
Thanks!!!!
Paul SomeoneElse
The text was updated successfully, but these errors were encountered: