Flask trim <datalist> 物品吗?

Does Flask trim <datalist> items?

在 Flask 中并使用 Jinja2,我调用了一个数据列表,但出于某种原因,任何带有 space 的选项都被修剪了,所以 "tomato sauce" 变成了 "tomato"。这是 Flask 正在做的事情还是我搞砸了模板?

<!-- HOMEPAGE -->
<form type="text" id="homeForm" class="centered" method="post" onsubmit="return false;">
        {{ form.hidden_tag() }}
        <input type="text" id="homeInput" autocomplete=off list="topps" placeholder="Input here">
        <datalist id="topps">
            {% for top in topps %}
            <option value={{ top }}>
            {% endfor %}
        </datalist>
        <button type="submit" id="homeSubmit">Submit</button>
</form>

# ROUTES.PY #
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def index():
    form = ToppingsForm()
    topps = ["tomato sauce", "chilli flakes","something else"]
    return render_template('index.html', title='Home', form=form, topps=topps)

您的问题在这里:

<option value={{ top }}>

{{top}}

之外添加引号
<option value="{{ top }}" />