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
)
Discussed in #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:
and in the template I have:
<link rel="stylesheet" href="{{ url_for('static', filename='stylesheets/main.css') }}">I feel that I shouldn't be passing
url_forin the globals but if I don't, then jinja complains that there's no such function. Where am I going wrong?