Module:User:Snaevar/test

From Wikidata
Jump to navigation Jump to search
Lua
CodeDiscussionLinksLink count SubpagesDocumentationTestsResultsSandboxLive code All modules

Documentation for this module may be created at Module:User:Snaevar/test/doc

Code

local p={}

function p.markup(frame)
   local args=frame.args
   local parent=frame.getParent(frame) or {}
   pargs=parent.args or {}
   local text=args.text or pargs.text
   local page=args.page or pargs.page
   if not text then
       page=mw.ustring.match(page,"%s*(.*%S)%s*") or ""
       if page=="" then
           title=mw.title.getCurrentTitle()
           assert(title.getContent, "Bug: [[Module:Test]] failed to get content of the current page")
           page=title.fullText
       else title=mw.title.new(page)
           assert(title.getContent, "Error: [[Module:Test]] failed to get content of "..page)
       end -- one way or another, we have a working getContent method
       text=title.getContent(title)
   end -- (not text) -- now we have text
   return text
end

return p