They may only have $5M in cap space available this year, but when you look at all their FAs, they actually have $23M for next year at the moment (assuming no increase in the cap).
https://www.capfriendly.com/teams/mapleleafs. Marner and Matthews won't be the problem... They'll get paid. The problem is going to be Kapanen (he'll want $4M-ish I suspect), as well as the others currently on the roster that would land in the $1M-$3M range (Johnsson, Leivo, Ennis, Lindholm & Sparks) plus a handful of minor-league players. Not to mention Hainsey and Gardiner as bigger ticket UFAs.
I think it's a great deal for Willie, bad deal for the team (Dubas caved... if this was the contract he was willing to offer, he should've just done it a month ago), and absolutely catastrophic for about 10 other GMs. There are easily ten other 2-year players that are ahead of Nylander in ability and value - Laine, Tkachuk, Rantanen, Aho, Boesser, Point, McAvoy, Werenski off the top of my head.
I'm thrilled to get him back, but it has all the possibilities of being a Lucic-ugly deal in the long term. I don't see him being a Leaf thru the entire 6 years to tell you the truth. I could go on and on over this, but not sure everyone wants to hear my ramblings over a 20-goal guy that isn't likely even to be on PP1 this year.