Module:Sandbox
Appearance
This is a sandbox module for testing of lua.
You can cteate your own sandbox like this:Module:Sandbox/Username.
-- <nowiki>
--
-- POC: Return first item marked by {{Security}} or {{Branching}} from {{MediaWiki News}}
-- (wasn’t checked for localisation in the process of making it)
--
local p = {}
local escapePattern = require( 'Module:String' )._escapePattern
local frame = mw.getCurrentFrame()
local templatePage = 'MediaWiki News'
local securityIcon = escapePattern( frame:expandTemplate{ title = 'Security' } )
local branchingIcon = escapePattern( frame:expandTemplate{ title = 'Branching' } )
function p._getImportantNews()
local text = frame:preprocess( '{{' .. templatePage .. '|condensed=1}}' )
local securityPos = mw.ustring.find( text, securityIcon )
local branchingPos = mw.ustring.find( text, branchingIcon )
local pos = securityPos > branchingPos and branchingPos or securityPos
local match = mw.ustring.match( text, '[%S ]+', pos )
return match
end
function p.getImportantNews(frame)
return p._getImportantNews()
end
-- Documentation page needed a function named run()
function p.run()
return 'This is a sandbox module for testing of lua.<br />You can cteate your own sandbox like this:<br /><code>Module:Sandbox/Username</code>.'
end
return p
-- </nowiki>