Skip to content

url_for support in templates? #314

Answered by mitsuhiko
itcld asked this question in Q&A
Jul 11, 2023 · 1 comments · 8 replies
Discussion options

You must be logged in to vote

actix-web makes this incredibly easy because the request object is cheaply clonable and can be stashed into a thread local. This means you can put it there before rendering, and then fetch that object back in a url_for function you can add to the template. I added an example that shows this: https://github.com/mitsuhiko/minijinja/blob/main/examples/actix-web-demo/src/main.rs

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@mitsuhiko
Comment options

@step21
Comment options

@mitsuhiko
Comment options

@step21
Comment options

@mitsuhiko
Comment options

Answer selected by mitsuhiko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants