I know how to make a personalized helper called or #isAdmin that verifies from my list of users who has the role of ADMIN, and based on that it shows me button to delete users etc, but I would not know how to do an if else if else with helper since I only have fn and inverse. I want if it is admin I get a badge, if it is TA other and DEV other
HBS ===>
<h1>{{title}}</h1>
<h3>{{usuarios}}</h3>
<ul class="list-group">
{{#each users as |user|}}
<li class="list-group-item">
{{user.username}}
<a href="/users/{{user.id}}">see profile</a>
{{#isAdmin user}}
<span class="badge badge-danger">ADMIN</span>
{{#elseif isTA user}}
<span class="badge badge-primary">TA</span>
{{else}}
<span class="badge badge-primary">DEV</span>
{{/isAdmin}}
{{!-- passportSession esta fuera de este scope del loop --}}
{{#isAdmin ../passportSession}}
<form action="/users/{{user._id}}/delete" method="POST">
<button type="submit" class="btn btn-danger float-right">x</button>
</form>
{{/isAdmin}}
</li>
{{/each}}
</ul>
===> HELPER FOR HBS
const constants = require('../constants');
const express = require('express');
const app = express();
module.exports = (hbs) => {
hbs.registerHelper('json', function(context){
return JSON.stringify(context);
});
hbs.registerHelper('isAdmin', (context, options) =>{
if (context.role === constants.BOSS) {
return options.fn(this);
} else{
return options.inverse(this);
}
});
hbs.registerHelper('isTA', (context, options) =>{
if (context.role === constants.TA) {
return options.fn(this);
} else{
return options.inverse(this);
}
});
};