Skip to content

Conversation

@joshuadavidthomas
Copy link
Owner

it's clear i need a rethink of parsing django block tags to nodes, becuase my mental picture of them differs from the actual use of them. E.g. I tend to think of them the same as HTML tags as either "void" tags or ones with end tags and children but not that's not the case at all. Some have intermediate tags ({% if %}{% else %}{% endif %}) which is not a huge lift to support, but the mind blowing realization was that it's just convention that the closing tag starts with end.

for builtin's, yeah that's it's the case that all of the tags that have opening and closing tags all close with a matching tag that is the initial tag with end prefixed. but given the flexibility of the django template engine, a third-party could feasibly use any closing tag it wanted. that makes it very hard to build a structured, full-featured AST for a Django template.

maybe that's not really needed for an LSP. but i'll need to come up with something eventually.

it's clear i need a rethink of parsing django block tags to nodes,
becuase my mental picture of them differs from the actual use of them.
E.g. I tend to think of them the same as HTML tags as either "void" tags
or ones with end tags and children but not that's not the case at all.
Some have intermediate tags (`{% if %}{% else %}{% endif %}`) which is
not a huge lift to support, but the mind blowing realization was that
it's just convention that the closing tag starts with `end`.

for builtin's, yeah that's it's the case that all of the tags that have
opening and closing tags all close with a matching tag that is the
initial tag with `end` prefixed. but given the flexibility of the django
template engine, a third-party could feasibly use *any* closing tag it
wanted. that makes it very hard to build a structured, full-featured AST
for a Django template.

maybe that's not really needed for an LSP. but i'll need to come up with
*something* eventually.
@joshuadavidthomas joshuadavidthomas merged commit b1b3e6a into main Dec 14, 2024
3 of 4 checks passed
@joshuadavidthomas joshuadavidthomas deleted the fix-blocks branch December 14, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants