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

Module:Test: Difference between revisions

From ProleWiki, the proletarian encyclopedia
m (Test function)
m (Added comments)
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}
function p.date(frame)
function p.test( frame )
local Date = os.date()
-- Get contents of page
local hour = Date:match("(%d+):%d+:%d+")
local pageContent = tostring(mw.title.getCurrentTitle():getContent())
local minute = Date:match("%d+:(%d+):%d+")
-- Split contents of page in lines
local second = Date:match("%d+:%d+:(%d+)")
local pageLines = mw.text.split(pageContent,'\n',true)
return hour .. ":" .. minute .. ":" .. second
local render = ''
for i=1,#pageLines do
-- Get every line starting with '==', that is, a header
if mw.text.split(pageLines[i], '%s')[1] == '==' then
render = render .. pageLines[i]
end
end
return render
end
end
return p
return p

Latest revision as of 19:16, 14 April 2024

local p = {}
function p.test( frame )
	-- Get contents of page
	local pageContent = tostring(mw.title.getCurrentTitle():getContent())
	-- Split contents of page in lines
	local pageLines = mw.text.split(pageContent,'\n',true)
	local render = ''
	for i=1,#pageLines do
		-- Get every line starting with '==', that is, a header
		if mw.text.split(pageLines[i], '%s')[1] == '==' then
			render = render .. pageLines[i]
		end
	end
	return render
end
return p