I have a large json file that requires a helper to split it. The file contains numbers in 2 ways:
“10 - 30” and “<100”
I need to split this data to remove the " - ", so only the first number is shown and just the “<”, to show only the number ( I still need to preserve original data as well).
I made two helpers for this:
Template7.registerHelper('siRangeSplit', function(siRange) {
var siRange;
if(siRange.indexOf('-') >= 0){
siRange = siRange.split('-');
} else if(siRange.indexOf('<') >= 0){
siRange = siRange.split('<');
}
return siRange[0]; siRange[1];
});
Template7.registerHelper('conventionalRangeSplit', function(conventionalRange) {
var conventionalRange;
if(conventionalRange.indexOf('-') >= 0){
conventionalRange = conventionalRange.split('-');
} else if(conventionalRange.indexOf('<') >= 0){
conventionalRange = conventionalRange.split('<');
}
return conventionalRange[0]; conventionalRange[1];
});
and call them like this:
{{siRangeSplit siRange}}
{{conventionalRangeSplit conventionalRange}}
I get the following error:
Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'siRange.indexOf')
Any help would be appreciated!