Mik*_* C. 0 python jinja2 flask
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)
Run Code Online (Sandbox Code Playgroud)
Template
<head>
<title>test</title>
</head>
<body>
<form>
test:<br>
<input type="text" name="test" value={{text}}>
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
Result
I want to populate with the entire string.
你需要引用周围{{text}}
这是呈现的内容:
<input type="text" name="test" value=My long test entry>
Run Code Online (Sandbox Code Playgroud)
这是您想要渲染的内容:
<input type="text" name="test" value="My long test entry">
Run Code Online (Sandbox Code Playgroud)
您的代码应如下所示:
<input type="text" name="test" value="{{text}}">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1787 次 |
| 最近记录: |