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 utils = require( 'Module:Utils' )


local ref = {}
local p = {}


function ref( text, id, group )
function ref( text, id, group )
Line 19: Line 19:
end
end


function ref.ref( frame )
function p.ref( frame )
local text = frame.args[1]
local text = frame.args[1]
local id = frame.args[2]
local id = frame.args[2]
Line 26: Line 26:
end
end


return ref
return p

Revision as of 15:27, April 25, 2021

vde
Lua Module Documentation

This module provides the backend implementations of the Ref templates.

Public Functions

p.ref

Private Functions

ref

Code

A copy of the code for this module follows:


local utils = require( 'Module:Utils' )

local p = {}

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 p.ref( frame )
	local text = frame.args[1]
	local id = frame.args[2]
	local group = frame.args[3]
	return ref( text, id, group )
end

return p