Populate a form using Flask / Jinja2 template. Input text fields are truncating data

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.

nos*_*wah 5

你需要引用周围{{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)