将python dict传递给模板

马什

必须有一种方法可以执行此操作...但是我找不到它。

如果我像这样将一个字典传递给模板:

@app.route("/")
def my_route():
  content = {'thing':'some stuff',
             'other':'more stuff'}
  return render_template('template.html', content=content)

这在我的模板中可以正常工作...但是有一种方法可以删除“内容”。, 从

{{ content.thing }}

我觉得我以前看过,但是找不到任何地方。有任何想法吗?

安德烈

尝试

return render_template('template.html', **content)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章