首页 > 解决方案 > 表单中带有模板文字的 EJS

问题描述

我需要在表单内的 action 道具中插入一个带有模板文字的 id。

例子:

  <div>
    <h6>Cookmaster - Receitas</h6>

    // Similar Template, but i need a EJS template

    <form action={`/recipes/${id}`} method="POST">
      <label for="title">Título da Receita</label>
      <input type="text" id="title" name="title" value=<%= title %>>
      <br>
      <label for="ingredients">Ingredientes</label>
      <textarea type="text" id="ingredients" name="ingredients" value=<%= ingredients %>></textarea> 
      <br>
      <label for="detailsRecipe">Modo de Preparo</label>
      <textarea type="text" id="detailsRecipe" name="detailsRecipe" value=<%= detailsRecipe %>></textarea>
      <br>
      <button type="submit">Enviar Receita</button>
    </form>
  </div>

但我不知道如何在这种情况下插入模板文字。

感谢帮助。

标签: javascriptejs

解决方案


经过多次尝试,有:

 <form action=<%= `/recipes/${id}` %> method="POST">

tks。


推荐阅读