'On SyntaxError: Unexpected Indentifier while compiling ejs problem
I have encountered the error below when running the app
SyntaxError: Unexpected identifier in /home/caio/Documents/cursoOneBitCode/expressTODOList/src/views/checklists/edit.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass `async: true` as an option.
at new Function (\<anonymous\>)
at Template.compile (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/ejs/lib/ejs.js:662:12)
at Object.compile (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/ejs/lib/ejs.js:396:16)
at handleCache (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/ejs/lib/ejs.js:233:18)
at tryHandleCache (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/ejs/lib/ejs.js:272:16)
at View.exports.renderFile \[as engine\] (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/ejs/lib/ejs.js:489:10)
at View.render (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/express/lib/view.js:135:8)
at tryRender (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/express/lib/application.js:640:10)
at Function.render (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/home/caio/Documents/cursoOneBitCode/expressTODOList/node_modules/express/lib/response.js:1017:7)
<%- include('../layouts/header', {title: Editar lista de tarefas}) %>
<%- include('../layouts/menu') %>
<section class="section">
<div class="container">
<h1 class="title size-4">Editar Lista</h1>
<%- include('form', {url: `/checklists/${checklist.id}/?_method=put`, checklist: checklist}) %>
</div>
</section>
<%- include('../layouts/footer') %>
<footer class="card-footer">
<p class="card-footer-item">
<span>
<a href="/checklists/<%= checklist._id %> ">Ver</a>
</span>
</p>
<p class="card-footer-item">
<span>
<a href="/checklists/<%= checklist.id %>/edit">Editar</a>
</span>
</p>
<p class="card-footer-item">
<span>
<a href="#" class="has-text-danger">Remover</a>
</span>
</p>
</footer>
router.put('/:id', async (req, res) => {
let { name } = req.body.checklist;
let checklist = await Checklist.findById(req.params.id);
try {
await checklist.update({name})
res.redirect('/checklists')
} catch (error) {
let errors = error.errors;
res.status(422).render('checklists/edit', {checklist: {...checklist, errors}})
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
