Your template is lovely, but there's a problem, it takes the upgrades in order, but the game doesn't order them by tier. Your example actually suffers from this problem. I don't know a ton about MW templates or how this might be fixed, but for now I can just manually reorder the templates.
It looks fucking great and very useful aside from that, though.
Well, hell. I didn't know the game spits them out like that. I didn't notice in my example either (never code while tired). I guess people will have to live with the inconvenience of reordering it, because I'm not totally sure how I would be able to compensate for it. Maybe we could just get the devs to change the export output. XD
Heh, good luck getting the devs to do anything useful. The game outputs them in instantiation order, I'm pretty sure, which goes by faction.
And yeah, I looked a bit at the parser functions features you used (plus I had to get them enabled on the shadow wiki on miraheze). They don't seem to really be smart enough to do anything like that. Maybe a scribunto module would be the way to go.