Jump to content

Module:Get short description

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Qwerfjkl (talk | contribs) at 14:39, 14 August 2022 ([Bawl!]). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}
function p.main(frame)
	local page = frame.args.page
	local nomatch = frame.args.nomatch   
	local sd = p._main(page, nomatch)									   
    return sd										   
										   
end

--args: 1 - ustring pattern, 2 - value if present, 3 - value if absent, 
--      page - page to test if not this page

function p._main(args)
	return args["1"] .. "|" .. args["2"] or ""
	-- if not args["1"] then
	-- 	local page = mw.title.getCurrentTitle().fullText
	-- else
	-- 	local page = args["1"]
	-- end
	-- local page = mw.title.new('Russia"')
	-- if not page then
	-- 	--bad title
	-- 	return args["2"] or ""
	-- end
	-- local content = page:getContent()
	-- return content

	-- if not content then
	-- 	--page does not exist
	-- 	return ""
	-- end
	-- content = frame:preprocess(content) -- expand content
	-- if mw.ustring.match(content, args["1"] or "") then
	-- 	if args["sub"] then
	-- 		--return value should have capture groups substed in
	-- 		local pattern = args["1"] or ""
	-- 		if mw.ustring.sub(pattern, 1, 1) ~= "^" then
	-- 			--pattern does not force it to be at start of page
	-- 			pattern = "^.-" .. pattern
	-- 		end
	-- 		if mw.ustring.sub(pattern, -1) ~= "$" then
	-- 			--pattern does not force it to be at end of page
	-- 			pattern = pattern .. ".*$"
	-- 		end
	-- 		--pattern will now match entire content, so running gsub will
	-- 		--return the string that has been passed in parameter 2 with things
	-- 		--like %1 substituted, NOTE: %0 does not work in this
	-- 		local out = mw.ustring.gsub(content, pattern, args["2"] or "")
	-- 		return out
	-- 	else
	-- 		return args["2"] or ""
	-- 	end
	-- else
	-- 	return args["3"] or ""
	-- end
end

return p