Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass variable to #each in handlebars?

I have template that looks like this:

calling it:

  {{Gd-text-input label="Specify" name="Specify" key="entry.810220554" hideIf=true}}

The template:

  <script type="text/x-handlebars" data-template-name='components/Gd-radio-input'>
    {{log key}}
      {{#each content}}
        {{log key}}
        <div class="radiobutton">
          {{radio-button id=label value=label name=key }}
          <label {{bind-attr for="label"}}>{{label}}</label>
        </div>
      {{/each}}
  </script>

The first log key outputs asdf. The one inside the #each – loop is undefined. How can I tell the Each-loop about the variable or access it from outside the loop?

like image 565
Himmators Avatar asked Jul 31 '26 11:07

Himmators


1 Answers

view.key is what is needed, so

 {{log view.key}}

will output the variable-name

like image 65
Himmators Avatar answered Aug 03 '26 02:08

Himmators



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!