-1

How can I use a variable containing string 'nav' (from a markdown file) instead of nav (a json file) in: {{#each nav}} {{this}} {{/each}} As I have more than one nav.json file, if I use a variable from the respective markdown file, I want it to loop through the respective json file with the same filename as the variable from markdown.

Any help?

xpark
  • 51
  • 1
  • 11

1 Answers1

1

First of all your Question is not clear that what condition you want to achieve.

so i guess an one attempt that, Use JavaScript Array Variable like the object of language Array you mentioned

var language = ['english','marathi','hindhi','telugu'];
var result = [];

 language.forEach(function(eachElement) {
      // roam here if you want to do more .....
     result.push('nav'+eachElement.charAt(0));
  });

so the result would be ['nave','navm', 'navh', 'navt']

After that use this result Array in Handlerbar #each loop as your condition

hari
  • 165
  • 1
  • 1
  • 12