Look very, very carefully at your pastebinned code compared to Wikipedia's code. In fact, I'd recommend performing a diff of the two.
Your code
metatable._index = function(t, key)
local ret = rawget(t, key)
if ret then
return ret
end
ret = metatable[key]
if type(ret) == 'function' then
return function(...)
return ret(t, ...)
end
else
return ret
end
end
Wikipedia
metatable.__index = function(t, key)
local ret = rawget(t, key)
if ret then
return ret
end
ret = metatable[key]
if type(ret) == 'function' then
return function(...)
return ret(t, ...)
end
else
return ret
end
end
Do you see the difference? Metamethods in Lua always start with two underscores __
, not one. I'm not sure how your code got to the state that it's in, but this would very well explain all the troubles you've been having, even why attr
was not accessible. It was due to the metatable's __index
field lacking an underscore, which of course means that it would not be recognized at all. I'm surprised I noticed, since it's easy to miss that extra underscore when skimming.
I would recommend restoring your HtmlBuilder
module to its original state first then see if that fixes your issue. You might want to restore NavBox
and any others you may have modified, if your modifications aren't too significant, but a diff would definitely tell you what's different between your versions.
Just be mindful of what you change in the future, but don't be afraid to experiment so long as you have backups!