I'm working on creating a "garage sale-isque" page and currently learning handlebars.
I'm trying to call a function from within one of the properties' definitions and have the returned value be the property value.
The setup I have right now is:
var lawnGarden = [{
title: "Lawn Mower",
price: 75.00,
img: "./img/lawnMower.jpg",
desc: "Great mower, kept in great condition, runs smooth.",
link: genLink(this.title);
}, {
title: "Hedge Clippers",
price: 25.00
}, {
title: "Shovel",
price: 10.00
}, {
title: "Post Hole Digger",
price: 20.00
}]
function genLink(title) {
var baseURL = "https://pensacola.craigslist.org/search/sss?sort=rel&query=";
return baseURL + title.replace(" ", "%20");
}
Is there anyway for me to do this? Or perhaps a better way?
I should mention I'm working in nodeJS.