Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Handlebars.js context in a template

Is there a variable passed into every handlebar.js template that contains all the context content that is accessible by the template?

e.g. I'm creating a template, but I don't know all the context content accessible by the template. I want to be able to type into the template {{ debug }} and handlebars.js will spit out all the context content into the HTML

like image 306
Tri Noensie Avatar asked Jun 27 '12 17:06

Tri Noensie


1 Answers

You can use the following code to iterate through this object:

{{#each this}}
  {{@key}}: {{this}}
{{/each}}

or a similar piece of code iterating through @root object:

{{#each @root}}
  {{@key}}: {{this}}
{{/each}}
like image 172
CaptainRR Avatar answered Oct 21 '22 15:10

CaptainRR