Handlebars - reaching up to a value in the parent context

 

I had a weird situation where my data looked like this (the object that gets passed into the template function):

{
isAdmin: true,
items:[......]
}

 

In my template I was looping through the items but within that loop I had to reach back up to the parent context to check the isAdmin value, this seems strange but this is how I got it to work.

{{#each items}}
{{#if ../../isAdmin}}
html for admins goes here
{{else}}
html for non admins goes here
{{/if}}
{{/each}

 

Add a Comment...

 

Comments

Thanks very nice blog! - 9/25/2016

I believe this can be amongst the most vital information for me personally. And i am glad reading your article. But should remark on few general things, The website style is ideal, the articles is actually excellent : D. Good job, cheers - 9/24/2016

Hey there, I think your blog might be having browser compatibility issues. When I look at your blog site in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, great blog! - 9/12/2016

Georgiahp Liverpool VanSturgi GonzaloLa Los Angeles Galaxy MicheleCo LucienneM West Ham United TaniaMcCu ChetMagee Olympique Lyonnais ChandraWi TarahRaym BVB Borussia Dortmund TeganGarn - 3/08/2017

BN - 2/22/2017

I was suggested this website by means of my cousin. I am no longer positive whether this submit is written by means of him as nobody else understand such distinctive approximately my problem. You're incredible! Thank you! - 2/20/2017

Definitely believe that that you stated. Your favorite reason seemed to be with the web the easiest thing to remember of. I only say to you personally, I definitely get irked whilst other people consider concerns that they just don't know about. You controlled going to the nail upon the best plus defined out everything without having need side-effects , other people could take a signal. Will probably be again to obtain more. Thanks - 11/23/2016

I used to be wondering if you thought about changing the structure of your own blog? Its well written; I adore what youve reached say. But you could possibly could a little more when it comes to content so people could interact with it better. Youve got a great deal of text for only having one or 2 images. Perhaps you could space it out better? - 11/18/2016

Wow that was odd. I just wrote an very long comment but after I clicked submit my comment didn't show up. Grrrr... well I'm not writing all that over again. Anyhow, just wanted to say fantastic blog! - 11/15/2016

Appreciate this post. I want to give it a try. - 11/14/2016