JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.js"></script>
<div id="output"></div>
<script type="template/handlebars" id="template">
-------------------------<br/>
--OBJECT-----------------<br/>
-------------------------<br/>
{{#each this.data}}
<br/>Unless Version:<br/>
{{#unless (lookup ../dontDisplay @key) }}
{{#if ..}}
{{else}}
!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!<br/>
{{/if}}
{{../path}}.{{@key}}: {{.}}
<br/> this:{{.}}
<br/> parent:{{..}}
<br/>
{{else}}
{{#if ..}}
{{else}}
!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!<br/>
{{/if}}
{{../path}}.{{@key}}: --Property Skipped Correctly--<br/>
{{/unless}}
<br/>If/Else Version:<br/>
{{#if (lookup ../dontDisplay @key) }}
{{#if ..}}
{{else}}
!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!<br/>
{{/if}}
{{../path}}.{{@key}}: {{.}}
<br/> this:{{.}}
<br/> parent:{{..}}
<br/>
{{else}}
{{#if ..}}
{{else}}
!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!!FAIL!!<br/>
{{/if}}
{{../path}}.{{@key}}: --Property Skipped Correctly--<br/>
{{/if}}
<br/>Regular Version:<br/>
{{../path}}.{{@key}}: {{.}}
<br/> this:{{.}}
<br/> parent:{{..}}
<br/><br/>
---
<br/>
{{/each}}
<br/>
-------------------------<br/>
--ARRAY-----------------<br/>
-------------------------<br/>
{{#each this.data2}}
<br/>Unless Version:<br/>
{{#unless (lookup ../dontDisplay @key) }}
{{#if ..}}
{{else}}
...
JavaScript
var template = Handlebars.compile(document.getElementById('template').innerHTML);
document.getElementById('output').innerHTML = template(
{
path: "rootObject",
data:
{
asfd:1,qwer:"qwer", zxcv: null, rewq:null
}
,data2:[1,"qwer", null, null]
,dontDisplay:
{
//asfd:1,
qwer:true
,1:true
,rewq:true
,3:true
}
}
);