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
.data
is completely valid there. Problem I have is in<h1>
,blockId
doesn't print anything. The reason that's causing this is the loop of#each data
. As soon as I remove the loop,blockId
is correct after that. What I want is thatblockId
should be the same for all elements ofdata
.How can I grab the parameter from url in
handlebars
file to passa href
element? In this case, I would not need to returnblockId
again from express.