Wednesday, 10 May 2017

handlebars function server

i want to execute a back function in the template handlebars but i dont know the good way. someone have idea ?

controller:

const addToFavorite = (product__c) => favorite.create({product__c})

router.get('/', checkSession, (req, res) => {
res.render('index', {addToFavorite, product: 'a0r0S000000MEcPQAW'}) })

client:

<button onclick=''> test </button>

helpers:

stringifyFunc (fn, p2, { hash }) {
  const product = hash.product
  return new Handlebars.SafeString("(" +
             fn.toString().replace(/\"/g,"'") +")("+ '"' + product +  '"' +")");
}

but i got "favorite is not defined" because is executed in client.

thanks



via Sofiane KHATIR

No comments:

Post a Comment