Module:Ref: Difference between revisions

From Halopedia, the Halo wiki

No edit summary
No edit summary
Line 1: Line 1:
local utils = require( 'Module:Utils' )
local ref = {}
local ref = {}


function ref.ref( text, group, id )
function ref( text, id, group )
if text == nil or text == '' then
return utils.error( 'No reference text was specified!', 'ref', 'Pages with empty citations' )
end
text = tostring( text )
text = tostring( text )
local args = {}
local args = {}
if id ~= nil and id ~= '' then
args.name = tostring( id )
end
if group ~= nil and group ~= '' then
if group ~= nil and group ~= '' then
args.group = tostring( group )
args.group = tostring( group )
end
if id ~= nil and id ~= '' then
args.name = tostring( id )
end
end
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
return text --frame:extensionTag( 'ref', text, args )
return frame:extensionTag( 'ref', text, args )
end
 
function ref.ref( frame )
local text = frame.args[1]
local id = frame.args[2]
local group = frame.args[3]
return ref( text, id, group )
end
end


return ref
return ref

Revision as of 15:26, April 25, 2021

vde
Lua Module Documentation

This module provides the backend implementations of the Ref templates.

Public Functions

ref.ref

Private Functions

ref

Code

A copy of the code for this module follows:


local utils = require( 'Module:Utils' )

local ref = {}

function ref( text, id, group )
	if text == nil or text == '' then
		return utils.error( 'No reference text was specified!', 'ref', 'Pages with empty citations' )
	end
	text = tostring( text )
	local args = {}
	if id ~= nil and id ~= '' then
		args.name = tostring( id )
	end
	if group ~= nil and group ~= '' then
		args.group = tostring( group )
	end
	local frame = mw.getCurrentFrame()
	return frame:extensionTag( 'ref', text, args )
end

function ref.ref( frame )
	local text = frame.args[1]
	local id = frame.args[2]
	local group = frame.args[3]
	return ref( text, id, group )
end

return ref