Template7 helper error

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!

Где у вас “splitTitle” helper?

Sorry, that error was from another attempt:

the error is

Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'siRange.indexOf')

remove: var siRange;

Same error when I remove the var

В месте, где вызывается код, siRange значит undefined

1 Like

Is this possibly due where I call my template7 helper? I put the code in app.js, after
var app = new Framework7({…