Inside a template variable, you're pretty much in "Python mode". So you would just use the variables directly, missing out both the braces and the quotes:
{{ url_for('named_url', slug=x.slug) }}
Question
In my template I have:
<a href="{{ url_for('named_url', slug=x.slug) }}">x.name</a>
In views:
webapp2.Route('/smth/<slug>/', handler=SomeHandler, name='named_url'),
I get this error:
ValueError: URI buiding error: Value "" is not supported for argument "slug".
I also tried:
<a href="{{ url_for('named_url', slug={{x.slug}}) }}">x.name</a>
and
<a href="{{ url_for('named_url', slug='{{x.slug}}') }}">x.name</a>
but it doesn't work. When I print {{x.slug}} somewhere else in the template it prints the correct slug. Also When I hard code slug='some_slug'
it also works.
La solution 2
Inside a template variable, you're pretty much in "Python mode". So you would just use the variables directly, missing out both the braces and the quotes:
{{ url_for('named_url', slug=x.slug) }}
Autres conseils
I, too, have experienced this ValueError and (through some trial and error) discovered that it is caused by the specified route definition lacking a regular expression.
In other words, try altering your route to be something like:
webapp2.Route('/smth/<slug:.*>/', handler=SomeHandler, name='named_url'),