Javascript and Dynamic Content | Community
Skip to main content

Javascript and Dynamic Content

  • April 4, 2022
  • 1 reply
  • 0 views

Carlos18

Hey there,

I'm currently working on Zendesk themes customizations and I'm using dynamic content helpers inside my javascript file (to be specific inside new_request.hbs page), in this particular way:

console.log(`{{ dc 'general_question' }}`);

But I would like to make my logic more dynamic, so I want to add variables inside the dynamic content helper, is this an option ? For example:

console.log(`{{ dc '${javascript_variable}' }}`);

I tried this approach but didn't work, maybe you guys have an idea ? 
Thanks !

1 reply

Tipene
  • April 6, 2022
Hey Carlos,
 
You can't use javascript variables to dynamically set the parameters of a handlebars helper, unfortunately. Depending on your use case, one way you could go about this is by conditionally rendering the appropriate dynamic content using #is statements in your .hbs template files.
 
Feel free to reach out with any questions!
 
Tipene