在ejs中为输入赋值

Assigning value to input in ejs

我想给输入字段赋值。当我 console.log 时,我得到了输出,因为 title is welocme to the app.内容是你好世界。但是只有 welcome 分配给标题输入,只有 hello 分配给内容输入。仅分配第一个单词。请帮忙

post.ejs

<%- include('./partials/header');-%>
<%- include('./partials/flash');-%>

<form action="/posts/<%= post._id %>/edited" method="POST">
  <%= console.log("title is "+post.Title +" ."+"content is "+post.Content); %>
  <h1><input type="text" name="title" id="title" value=<%= post.Title %>></h1>
  <p><input type="text" name="content" id="content" value=<%= post.Content %>></p>
  <button class="btn btn-primary" type="submit">Publish</button>
</form>

<%- include('./partials/footer');-%>

将 ejs 变量括在引号内。

//enclose like this
value="<%= post.Title %>"
value="<%= post.Content %>"

<h1><input type="text" name="title" id="title" value="<%= post.Title %>"></h1>
<p><input type="text" name="content" id="content" value="<%= post.Content %>"></p>