litestar-org / litestar

Production-ready, Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs
https://litestar.dev/
MIT License
5.44k stars 372 forks source link

Bug: using a custom jinja Environement seems to bypass a potential template callable #3791

Open euri10 opened 2 hours ago

euri10 commented 2 hours ago

Description

if using a custom env like described in https://docs.litestar.dev/2/usage/templating.html#registering-a-custom-template-engine I cannot add template callables, the registration is bypassed

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

latest

Platform


[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.

Fund with Polar

euri10 commented 2 hours ago

one could argue given the note in the docs that the registration "should" be done manually:

The instance parameter passed to TemplateConfig can not be used in conjunction with the directory parameter, if you choose to use instance you’re fully responsible on the engine creation.

I sent a PR nonetheless but that's really open to interpretation, I'm not unhappy if it is not automatic, it's entirely possible to do the same "manually" and to be fair I just realize I already have to do it for the flashes plugin with: environment.globals.update(get_flashes=get_flashes)