Javascript and Dynamic Content



Posted Apr 04, 2022

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

1

1 comment

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

0


Sign in to leave a comment.

Didn't find what you're looking for?

New post