1
有沒有辦法在燒瓶渲染的忍者模板中放置斷點?也許可以讓你在模板中的各個點檢查模板可用的變量?我看到一個博客,說你可以在django https://opensourcehacker.com/2013/05/16/putting-breakpoints-to-html-templates-in-python/做到這一點希望有類似的燒瓶。燒瓶忍者模板中的斷點
有沒有辦法在燒瓶渲染的忍者模板中放置斷點?也許可以讓你在模板中的各個點檢查模板可用的變量?我看到一個博客,說你可以在django https://opensourcehacker.com/2013/05/16/putting-breakpoints-to-html-templates-in-python/做到這一點希望有類似的燒瓶。燒瓶忍者模板中的斷點
瓶具有app_context_processor
做出模板可用變量:
context處理器運行模板呈現前必須注入新的值到模板方面的能力。
class Letters():
A = 1
B = 2
@app.context_processor
def share_context():
return dict(Letters=Letters)
Now you can access this class
# index.html
{{ Letters.A }}
{% if Letters.B != 1 %}
...
{% endif %}