The EditToolbar currently loads the menus from variables with names (a)tpl1, (a)tpl2, (a)tpl3, etc. EditToolbar-core.js has a fixed number of menus defined (tpl1, atpl1, and atpl2), so the users can add their own menus by defining additional vars in their user JS with consecutive numbers: tpl2, atpl3, etc.
We would like to make this more flexible, allowing the menus to be added by gadgets—and in arbitrary user-decided combinations. The consecutively numbered variables restrict us, because: 1) each gadget should use a unique number that wouldn't collide with another gadget's var number and with any user-defined menus; 2) the current logic stops adding menus once an undefined var is encountered, which might easily happen if e.g. the user activates gadgets with vars tpl2, tpl3, tpl5. Because they hadn't activated the gadget with tpl4, the one with tpl5 won't be loaded as well.
We avoid those problems by replacing the consecutively numbered variables, each holding a menu, with a single array, where the menus are elements of the array. This actually makes the code cleaner as well, as we can simply iterate over the array elements, instead of using the unsafe eval to access the numbered variables.
For reasons of backwards compatibility, considering that some users may have defined custom menus in their user JS, we still check for defined (a)tpl{i} variables and load them into the new arrays. We do this for all i in {0..10}, that is we ignore missing vars (the old default tpl1, atpl2, and atpl2 are now gone) and we never check beyond (a)tpl10, which should be more that enough.