按照建议,我尝试在hogan.js文件中编写.html代码,该文件位于烧瓶结构的模板文件夹中。当我执行python文件时,索引页面呈现时会出现以下错误
jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: unexpected char u'#' at 36667我还附加了部分index.html代码如下。
<div class="cell link">
<a href="{{url}}"> >> view {{type}} details</a>
{{#console_id}}
<a href="/project/instances/{{console_id}}/vnc" class="vnc_window">» open console</a>
{{/console_id}}
</div>python文件代码
@app.route('/')
def index():
return render_template('index.html')我还包括了hogan.js文件
<script src="{{ url_for('static', filename='horizon/lib/hogan-2.0.0.js') }}" type="text/javascript"></script>请帮我找出这个错误。
发布于 2013-09-19 08:00:29
您可以尝试像这样转义hogan标记:
{{ '{{#console_id}}' }}否则,烧瓶将其视为金刚模板的一部分,并试图在花括号中计算表达式。
如果要避免自动转义,可以使用safe筛选器。
{{ '{{> table1}}' | safe }}https://stackoverflow.com/questions/18889085
复制相似问题