aio-libs / aio-libs/aiohttp-jinja2

How do I employ cache busting in a template?

未關閉
#673 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
240
分支
61
平均合併
2 分鐘
30 天內合併 PR
4

描述

### 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?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。