Anyone knows how to concatene a string with a dynamic data for passe it into a form template?
My controller is :
exports.edit = function(req, res) {
var id = req.params.id;
Product.findOne({id: id}, function(err, doc){
if (err) {
res.send("There is no product with this " + id + "!")
} else {
res.partial('products/edit', {title: "Edit", product: doc});
}
});
};
my products/edit.jade file is :
-if (product != null)
h2 Edit
form.form-edit(method="post", action="products/#{product.id}", name="form-edit")
!=partial("inc/form-edit", { type: "Edit", image: "../img/" + #{product.image}})
// Doesn't work, i can pass only strings to my form template
and my inc/form-edit.jade file is:
.....
input#bt-prod-edit.btn.btn-primary(type="button", value="Parcourir")
img(src="#{image}")
div.align-center
input.bt-cancel.btn(type="button", name="bt-cancel", value="Annuler")
input#bt-prod-edit.btn.btn-primary(type="submit", name="bt-prod-edit", value="#{type}")
So if I do
!=partial("inc/form-edit", { type: "Edit", image: "image_path"})
works fine but if I try to passe any dynamic data I have an error message : Unexpected token ILLEGAL
Does anyone know why?
Thank you very much
Instead of:
!=partial("inc/form-edit", { type: "Edit", image: "../img/" + #{product.image}})
Try:
!=partial("inc/form-edit", { type: "Edit", image: "../img/" + product.image})