我有一个像这样定义的路线:
@app.route('/magic/<filename>')
def moremagic(filename):
pass
Run Code Online (Sandbox Code Playgroud)
现在在模板中我想用url_for()这样的方式调用该路由:
<h1>you uploaded {{ name }}<h1>
<a href="{{ url_for('/magic/<filename>') }}">Click to see magic happen</a>
Run Code Online (Sandbox Code Playgroud)
我试过了:
<a href="{{ url_for('/magic', filename={{ name }}) }}">Click to see magic happen</a>
Run Code Online (Sandbox Code Playgroud)
那扔了一个 jinja2.TemplateSyntaxError: expected token ':' got }
任何人都可以建议如何{{ name }}将模板中出现的内容输入到url_for()所以当我点击时我调用正确的app.route?
我无法在 Jinja2 示例中设置变量内部使用变量。
解决方案必须与Pelican兼容。
Any text
Goddess Kira greatest of all time!
Goddess Kristina greatest of all time!
Another text
Goddess Sasha greatest of all time!
Goddess Katya greatest of all time!
Run Code Online (Sandbox Code Playgroud)
Any text
Goddess Kira greatest of all time!
Goddess Kristina greatest of all time!
Another text
Goddess Sasha greatest of all time!
Goddess Katya greatest of all time!
Run Code Online (Sandbox Code Playgroud)
我有重复的Goddess和greatest of all …