handlebars.js - How to get reference to json key name inside {{#with}} helper? -


i want draw fields using handlebars partial have key name , value. json this:

{ "someknownfield" : { "textvalue" : "the value want" } }

i want label someknownfield text, , input value of textvalue in it. use partial because have hundreds of these fields , don't want have hard code names.

here's partial code, called textfield

<div class="control-group">   <label class="control-label" for="input{{@key}}">{{@key}}</label>   <div class="controls">     <input type="text" id="input{{@index}}" placeholder="{{@key}}" value="{{textvalue}}">   </div> </div> 

now, can't use {{#with}} helper, a-la {{#with someknownfield}}{{> textfield}}{{/with}} since doesn't give @key. {{#each}} has @key of context within each node (textvalue); how key key name of each node itself?

this not work, demonstrates need grab:

<label>{{../@key}}</label> 

since it's expecting id in parent path, not calculated value (which doesn't exist anyway, since it's not array itself).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -