Module:User:Mr. Stradivarius/sandbox
Appearance
![]() | This is the module sandbox page for Module:User:Mr. Stradivarius. |
local p = {}
-- This function displays the source wikitext of the page [[Wikipedia:Lua]]. To
-- run it, type in "=p.wplua()" to the Scribunto debug console (at the bottom of
-- this page in edit mode) and press enter. To run the function from a wiki
-- page, use {{#invoke:User:Mr. Stradivarius/sandbox|wplua}}.
function p.wplua()
local title = mw.title.new('Wikipedia:Lua') -- Makes a "title object" for the page [[Wikipedia:Lua]]
return title:getContent() -- Returns the page's content
end
-- This function does the same as the one above, but it can display the wikitext
-- for any page. To run it, use
-- {{#invoke:User:Mr. Stradivarius/sandbox|page|my page name}} from a wiki page.
function p.page(frame)
local pagename = frame.args[1] -- The first positional argument to #invoke
local title = mw.title.new(pagename)
return title:getContent()
end
return p