Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing tags in ejs template output #258

Open
TerjeRosenlund2 opened this issue Apr 10, 2023 · 0 comments
Open

Missing tags in ejs template output #258

TerjeRosenlund2 opened this issue Apr 10, 2023 · 0 comments

Comments

@TerjeRosenlund2
Copy link

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant