Exporting tables directly

Jump to navigation Jump to search

Exporting tables directly

If you want to use table data from another module, like at Module:form of, then it's a good idea to add in a comment in the module which other modules use it. That way, it's easier to change later. Functions can be tracked if needed to rename them, but tables can't.

CodeCat18:44, 16 May 2014

Actually, they can:

export.whatever = nil

setmetatable(export, {
	__index = function (self, key)
		if key == 'whatever' then
			require('Module:debug').track('whatever')
			return whatever
		end
	end
})

But I agree, annotating these is a good idea.

Keφr18:48, 16 May 2014

That code snippet would be very useful to preserve on Category:Template tracking!

CodeCat18:50, 16 May 2014