在Flask模板中运行Ember-Table

Run Ember-Table in Flask template

本文关键字:运行 Ember-Table Flask      更新时间:2023-09-26

我正在用Flask和Ember-Table制作一个应用程序。Jinja2运行在服务器端,Handlebars将运行在客户端。我使用{% extends "layout.html" %}{% block content %}从Jinja2和烬表的简单例子在同一模板(home.html)。当我运行上面的代码时:

@app.route('/')
def home():
    return render_template('home.html')

我有这个错误:

jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: expected token 'end of print statement', got 'hasFooter'

我所理解的是,Jinja2想要解释Ember,这是错误的。我能解决谁的问题?

使用{% raw %}让Jinja忽略模板的一部分:

{% raw %}
<body>
  <script type="text/x-handlebars">
    <h2> Welcome to Ember Table!</h2>
    <p>Version 0.2.0</p>
    {{outlet}}
  </script>
  <script type="text/x-handlebars" data-template-name="index">
    <div class="table-container">
      {{table-component
        hasFooter=false
        columnsBinding="columns"
        contentBinding="content"
      }}
    </div>
  </script>
</body>
{% endraw %}