Here is my route.
router.get("/blocks/:id", (req, res) => {
res.render("../views/block", {
data: data,
blockId: req.params.id,
});
});
Here is my view
<div class="row">
{{#each data}}
<div class="col">
<div class="card" style="width: 18rem;">
<div class="card-body">
<h1>/blocks/{{blockId}}</h1>
</div>
</div>
</div>
{{/each}}
</div>
In my view, I loop through the
data.datais completely valid there. Problem I have is in<h1>,blockIddoesn't print anything. The reason that's causing this is the loop of#each data. As soon as I remove the loop,blockIdis correct after that. What I want is thatblockIdshould be the same for all elements ofdata.How can I grab the parameter from url in
handlebarsfile to passa hrefelement? In this case, I would not need to returnblockIdagain from express.