Skip to content

#each over an array entered in config #1423

Closed Answered by michaelthwaite
michaelthwaite asked this question in Help
Discussion options

You must be logged in to vote

Solved:

I added a helpers.js file to the root of the theme containing a helper to convert a JSON string to an array :
`
/*

  • Custom theme helpers for Handlebars.js
    */

let themeHelpers = {
deserialize: function (value) {
try {
return JSON.parse(value);
} catch (e) {
console.error(e);
return [];
}
}
};

module.exports = themeHelpers;
`

Then consume the array:

{{#each (deserialize @config.custom.myJsonString)}} {{feature}} {{description}} {{/each}}

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@candidexmedia
Comment options

@michaelthwaite
Comment options

@candidexmedia
Comment options

@michaelthwaite
Comment options

@candidexmedia
Comment options

Answer selected by michaelthwaite
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants