aio-libs / aio-libs/aiohttp-jinja2

How do I employ cache busting in a template?

Aperta
#673 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
240
Fork
61
Merge medio
2m
PR unite (30g)
4

Descrizione

### Discussed in https://github.com/aio-libs/aiohttp-jinja2/discussions/590

Originally posted by **ugyballoons** July 22, 2022
Hi,
I'm enjoying working with aiohttp and jinja2.
It's not clear to me how to employ cache busting. Please could someone help?
In the setup I have:
```
sub_app.add_routes(
[
web.static(
"/static",
Path(__file__).parent / "static",
name="static",
append_version=True,
),
]
)
sub_app["static_root_url"] = "/path-to/static"
env = aiohttp_jinja2.get_env(sub_app)
env.globals.update(
zip=zip,
url_for=web.Resource.url_for
)
```
and in the template I have:
``

I feel that I shouldn't be passing `url_for` in the globals but if I don't, then jinja complains that there's no such function. Where am I going wrong?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.