Tim
April 15, 2020, 1:20pm
1
In previous Framework7 / Template7 versions, I used this custom helper:
Template7.registerHelper('for', function(arg, options) {
var t = '';
fn = 'for(' + arg + ') { t = t + options.fn(this, options.data); }';
eval(fn);
return t;
});
which I could use like this:
{{#for "i=0; i < 4; i++"}}
my index = {{i}}
{{/for}}
But in the current version this doesn’t work anymore. {{i}} seems to return some other data, but not my iterator variable.
Can’t see any problems with it, works for me:
Just tried to run this code in Framework7 kitchen sink, in console
Tim
April 15, 2020, 7:36pm
3
Thanks for your reply! Indeed, if I run the code in the console, it returns the expected result. But when I add exactly the same code to my component body, the iterator seems empty, altough it does run 4 times correctly. Maybe I’m overlooking something?
Weird enough, this works correctly. Looks like somewhere the context gets mixed up with something else and i
and j
are already used.
{{#for "abc=0; abc < 4; abc++"}}
id = {{js "abc"}}
{{/for}}
That the issue of using eval
How i can i add this to a component page?