I have the following scenario
{{#each (concatArray setra.features lion.features)}}
<tr>
<td><h4 class="ui header">{{this}}</h4></td>
<td>{{#if contains ../setra.features this}}YES{{/if}}</td>
<td>{{#if contains ../lion.features this}}YES{{/if}}</td>
</tr>
{{/each}}
where concatArray
is a helper function that returns an array of strings which is a concatenation of all features.
How do I properly write the statement above?
From within the each clause I am able to access the setra.features and lion.features by escaping the each context:
{{#each (concatArray setra.features lion.features)}}
{{../setra.features}} <!-- is accessible -->
{{/each}}
But once I want to use either as an argument in my helper function contains
, it gives me errors depending on how I try to implement it. The example above currently gives me a "Cannot read property 'includeZero' of undefined" error, which seems most likely because the path is not properly evaluated.
The helper functions are as follows:
var contains = function(array, string){
if(array && array.indexOf(string) > -1){ return true; }
return false;
}
exports.contains = contains;
var concatArray = function(array1, array2){
var newArray = array1;
array2.forEach(function(element){
if(newArray.indexOf(element) < 0){
newArray.push(element);
}
});
return newArray;
}
exports.concatArray = concatArray;