Open TerjeRosenlund2 opened 1 year ago
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>
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:
Console output:
Rendered html: