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

Module:Test2

From ProleWiki, the proletarian encyclopedia
Revision as of 12:36, 23 April 2024 by Forte (talk | contribs) (Refining capture so that it captures more than a single word)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
function splitLines(text)
    local lines = {}
    for line in text:gmatch("[^\r\n]+") do
        table.insert(lines, line)
    end
    return lines
end

local p = {}

function p.Sitename(frame)
	local extDataTable = mw.ext.externalData.getExternalData(frame.args[1])[1]["__text"]
	local dataLines = splitLines(extDataTable)
	local sitename = ''
	for i,line in ipairs(dataLines) do
		if line:match("og:site_name") then
			sitename = line:match('content="([^"]+)"')
			break
		end
	end
	return sitename
end

return p