Module:Sandbox/Jackmcbarn/variables

From Omniversalis

Documentation for this module may be created at Module:Sandbox/Jackmcbarn/variables/doc

local p = {}

function p.set(frame)
	frame:extensionTag{name = 'ref', content = frame.args[2], args = { group = 'lower-greek', name = frame.args[1] }}
	return ''
end

function p.get(frame)
	local refText = mw.text.unstrip(frame:extensionTag{name = 'references', args = { group='lower-greek' }})
	local keyMatch = mw.ustring.gmatch(refText, '<li id="cite_note%-([^-]*)%-%d+">')
	local valMatch = mw.ustring.gmatch(refText, '<span class="reference%-text">([^<]*)')
	local variables = {}
	for key in keyMatch do
		variables[key] = valMatch()
		frame:extensionTag{name = 'ref', content = variables[key], args = { group = 'lower-greek', name = key }}
	end
	return variables[frame.args[1]]
end

function p.done(frame)
	frame:extensionTag{name = 'references', args = { group='lower-greek' }}
	return ''
end

return p