0

So, I was making an HTML template in Flask And Wanted To Put The Form Label As The PlaceHolder Of A TextBox, But when I try to do so, Flask gives an error.

My Code:

<div class="input">
    {{ form.username(class="txtb", placeholder={{ form.username.label }}) }}

The Error Flask Gives:

jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'

And when I try to print the label normally like

<h4>{{ form.username.label }}</h4>

It works completely fine.

Also, this also works perfectly.

<div class="input">
    {{ form.username(class="txtb", placeholder="Username") }}

I Don't Know Where I Went Wrong.

Thanks In Advance!

4

1 回答 1

1

You probably want to use label's text because as you noticed label itself is full <label> element.

{{ form.username(class="txtb", placeholder=form.username.label.text) }}

于 2019-09-27T21:29:55.603 回答