We need to create an extra object in the $session templating variable that takes each phs_id from the objects in the $session.client.extensions.ras_dbgap_permissions array. Each phs_id should be used as a key in the created object with true as the value.
This is being done for a CFDE use case to prevent looping over a potentially large array for every single generated template. Array.includes() could almost accomplish the same thing but doing so could be potentially dangerous given the ras_dbgap_permissions array is an unknown size. The array also includes objects so a simple Array.includes wouldn't solve this use case.
To work with this created map, we need to also enable the lookup helper from handlebars (further explained here. One thing to note about this helper is how it behaves with null and undefined. This helper will return the value associated with the key in the map even if the value is set to null or set to undefined. If the key isn't present, undefined will be returned (which is the expected behavior in JS.
We need to create an extra object in the
$session
templating variable that takes each phs_id from the objects in the$session.client.extensions.ras_dbgap_permissions
array. Eachphs_id
should be used as a key in the created object withtrue
as the value.This is being done for a CFDE use case to prevent looping over a potentially large array for every single generated template.
Array.includes()
could almost accomplish the same thing but doing so could be potentially dangerous given theras_dbgap_permissions
array is an unknown size. The array also includes objects so a simpleArray.includes
wouldn't solve this use case.To work with this created map, we need to also enable the
lookup
helper from handlebars (further explained here. One thing to note about this helper is how it behaves withnull
andundefined
. This helper will return the value associated with the key in the map even if the value is set tonull
or set toundefined
. If the key isn't present,undefined
will be returned (which is the expected behavior in JS.