散景中的Jinja2变量 [英] Jinja2 variables in bokeh
本文介绍了散景中的Jinja2变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一些变量传递给呈现Jinja模板的bokeh文档.
I'm trying to pass some variable to a bokeh document which renders a Jinja template.
代码是:
curdoc().template = template
curdoc().template_variables["testvar"] = "cia"
curdoc().add_root(row(p1,p2))
如果我根本不使用模板中的变量,并且不尝试通过template_variables访问它们,那么一切正常,但是使用上面的代码,我得到了错误:
If I don't use variables at all in the template and don't try to access them via template_variables all works fine, but with the code above I get the error:
curdoc().template_variables["testvar"] = "cia"
AttributeError: 'Document' object has no attribute 'template_variables'
我用来启动应用程序的命令当然是:
The command I use to start the application of course is:
bokeh serve --show myapp
我在哪里做错了?
谢谢, 吉安
推荐答案
template_variables
是0.12.4
中新增的一个相对较新的功能.您需要升级到比当前安装的版本更高的Bokeh版本.
template_variables
is a relatively new feature added in 0.12.4
. You need to upgrade to a newer Bokeh version than whatever you have currently installed.
这篇关于散景中的Jinja2变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文