Skip to content

Missing tags in ejs template output #258

Description

@TerjeRosenlund2

The included template code is missing all LI-tags in the UL-tag

I'm using VSCode and the CODEGPT extension suggests exactly the same code so I suspect it's a bug in EJS

Template code:

<%
const dbQuery = function(mysql)  {
  return new Promise((resolve, reject) => {
    con.query(mysql, (err, result) => {
      if (err) {
        reject(err);
      }
      else {
        resolve(result);
      }
    }); 
  });  
}
%>
<h2>Products</h2>
<ul>
  <% 
  dbQuery("SELECT * FROM products")
  .then(products => { 
    console.log("Data received from database: ", products);
    products.forEach(product => {
      console.log("Product name: ", product.name);
      %>
      <li> <%= product.name %> </li>
    <%  } ) } )
  .catch(err => console.log("Error fetching data from database: ", err));
  %>
</ul>

Console output:

Data received from database:  [
  RowDataPacket { id: 1, name: 'Product 1', price: 101 },
  RowDataPacket { id: 2, name: 'Product 2', price: 51 },
  RowDataPacket { id: 3, name: 'Product 3', price: 12 }
]
Product name:  Product 1
Product name:  Product 2
Product name:  Product 3

Rendered html:

<ul>
  
</ul>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions