Module:Citation: Difference between revisions

From ProleWiki, the proletarian encyclopedia
No edit summary
mNo edit summary
Line 1: Line 1:
local p = {}
local p = {}
local function is_set (var)
return not (var == nil or var == '');
end


function p.cite( frame )
function p.cite( frame )
Line 6: Line 10:
Title = pframe.args.title
Title = pframe.args.title
Year = pframe.args.year
Year = pframe.args.year
return Author .. " (" .. Year .. ")" .. ". " .. "''" .. Title .. "''"
if is_set (Author) then
if is_set (Year) then
return Author .. "(" .. Year .. ")" .. ". "
else
return Author .. ". "
end
end
end
end
return p
return p

Revision as of 19:30, 27 October 2021

local p = {}

local function is_set (var)
	return not (var == nil or var == '');
end

function p.cite( frame )
	local pframe = frame:getParent()
	Author = pframe.args.author
	Title = pframe.args.title
	Year = pframe.args.year
	if is_set (Author) then
		if is_set (Year) then
			return Author .. "(" .. Year .. ")" .. ". "
			else
				return Author .. ". "
		end
	end
end
return p