Skip to content

Conversation

@Kijewski
Copy link
Member

@Kijewski Kijewski commented Aug 1, 2025

Resolves #551.
Cc. @m4tx.

@Kijewski Kijewski added enhancement New feature or request derive Related to the code generating labels Aug 1, 2025
@Kijewski Kijewski force-pushed the pr-same-dir branch 2 times, most recently from 67c633b to 864235a Compare August 2, 2025 00:25
@Kijewski Kijewski marked this pull request as ready for review August 2, 2025 00:25
Comment on lines -398 to -406
Because top-level content from the child template is thus ignored, the `extends`
tag doesn't support whitespace control:

```html
{%- extends "base.html" +%}
```

The above code is rejected because we used `-` and `+`. For more information
about whitespace control, take a look [here](#whitespace-control).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replaced text was outdated since #241 / askama v0.13. Oops.

Comment on lines -699 to -703
The path to include must be a string literal, so that it is known at
compile time. Askama will try to find the specified template relative
to the including template's path before falling back to the absolute
template path. Use `include` within the branches of an `if`/`else`
block to use includes more dynamically.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what the sentence ↓ meant, so I removed it. :)

Use include within the branches of an if/else block to use includes more dynamically.

Copy link
Contributor

@m4tx m4tx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for implementing this! You've done this before I even had a chance to tackle this! (which is nice!)

I think there was a slight misunderstanding about what kind of macro we are talking about. In #551, the issue I've created, I meant we should look for templates in the Jinja/Askama macro caller directory (i.e. {% call macro() %})—you can see exactly what I meant by looking at the (failing) test case I've added here. This PR, on the other hand, adds a lookup in the Rust macro caller directory. Both fix my use case, however, so I'm satisfied either way!

Just one comment from me about the implementation.

"template {:?} not found in directories {:?}",
path, self.dirs,
path.display(),
self.dirs,
Copy link
Contributor

@m4tx m4tx Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this accurate? We check more directories than just self.dirs (even before the changes in the PR). I believe this should be changed so that this displays self.dirs along with start_at and caller_dir(), so it displays accurate information to the library user.

@GuillaumeGomez
Copy link
Collaborator

Since I opened #558, I'll wait for it to be merged first before approving this one if you don't mind. ^^'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

derive Related to the code generating enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Macros include files from the macro's declaration directory, rather than caller's

3 participants