Reputation: 1921
I am trying to send data to Flask Jinja2 template and repopulate a text input inside of a form. When I do this my data gets truncated. For example:
App.py
@app.route('/test')
def test():
text = 'My long test entry'
return render_template('test.html', text=text)
Template
<head>
<title>test</title>
</head>
<body>
<form>
test:<br>
<input type="text" name="test" value={{text}}>
</form>
</body>
Result
I want to populate with the entire string.
Upvotes: 0
Views: 2080
Reputation: 1744
You'll need quotes around {{text}}
Here's what renders:
<input type="text" name="test" value=My long test entry>
Here's what you want to render:
<input type="text" name="test" value="My long test entry">
Here's what your code should look like:
<input type="text" name="test" value="{{text}}">
Upvotes: 5