Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Test3: Difference between revisions

From ProleWiki, the proletarian encyclopedia
(Finalizing module, final testing)
(Improving logic and testing use of blockquote tags)
Line 10: Line 10:
function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
local args = frame:getParent().args
local blockquote = mw.html.create():tag('blockquote')
local String = ''
local String = ''
local counter = 1
local counter = 1
Line 21: Line 23:
end
end
if counter>1 then
if counter>1 then
return 'See main articles: ' .. String
blockquote:wikitext("''See main articles: " .. String .. "''")
else
else
return 'See main article: ' .. String
blockquote:wikitext("''See main article: " .. String .. "''")
end
end
return tostring(blockquote)
end
end
return p
return p

Revision as of 01:25, 27 April 2024

local p = {}

function wikilink(name)
	if name:sub(1,2) == '[[' and name:sub(-2) == ']]' then
		name = name:sub(3,-3)
	end
	return '[[' .. name .. ']]'
end

function p.main(frame)
	local args = frame:getParent().args
	local blockquote = mw.html.create():tag('blockquote')
	
	local String = ''
	local counter = 1
	for k,v in pairs(args) do
		if k == 1 then
			String = String .. wikilink(v)
			else
				counter = counter+1
				String = String .. ', ' .. wikilink(v)
		end
	end
	if counter>1 then
		blockquote:wikitext("''See main articles: " .. String .. "''")
		else
			blockquote:wikitext("''See main article: " .. String .. "''")
	end
	return tostring(blockquote)
end
return p