I'm currently facing an issue trying to chain an object rendered from Express in my Handlebars file. I can't seem to find a solution.
The object I'm working with is structured like this:
"generalContentOfferOne": {
"subCopy": {
"en-us": "Test Copy",
"bahasa": "Bergabunglah dalam..."
}
}
When I try to render
{{distributorJSON.generalContentOfferOne.subCopy}}
in my Handlebars file, it displays as Object object
, which is expected.
In addition, I have a localization variable that determines whether the language should be en-us
or bahasa
based on the route. I thought I could use bracket notation to dynamically render the value from the object above using the localization value. For example:
{{ distributorJSON.generalContentOfferOne.subCopy[{{localization}}] }}
I also attempted:
{{ distributorJSON.generalContentOfferOne.subCopy.{{localization}} }}
Unfortunately, these methods are not successful. I suspect that Handlebars might have its own specific way of chaining dynamic values. Any guidance would be greatly appreciated. Thank you!