Module:FormatTemplate/testcases

From blackwiki
< Module:FormatTemplate
Revision as of 16:35, 2 February 2014 by blackwiki>Wnt (Going to make this a different function name...)
Jump to navigation Jump to search

Note: as you can see, we're still a long way from Tipperary

Tiny example

 ---- beginning of module ----
local p = {}

getArgs = require('Module:Arguments').getArgs

p.main = function(frame)
args = getArgs(frame)

 -- begin variable table
local t_1 = args[1] and mw.text.trim(args[1])
local t_small = args['small'] and mw.text.trim(args['small'])
local p_0
 -- end variable table

 -- begin parser function translations
p_0_in = mw.text.trim((t_1 or "") .. "\n")
if p_0_in == mw.text.trim(" purpose ") then
p_0 = mw.text.trim(" This " ..
"[[" .. "WP:Drafts" .. "|" .. "draft" .. "]]" .. " does not appear to be intended as a potential article, and may be moved to a more appropriate namespace or deleted. Drafts of non-article materials such as policy essays, templates, and modules can be created in their normal namespaces or in userspace, because the encyclopedic quality standards do not apply to them.<includeonly>" ..
"[[" .. "Category:Drafts tagged with cleanup notices" .. "]]" .. "</includeonly>\n")
elseif p_0_in == mw.text.trim(" advocacy ") then
p_0 = mw.text.trim(" This " ..
"[[" .. "WP:Drafts" .. "|" .. "draft" .. "]]" .. " appears to be composed so as to argue a position or advertise a product rather than to present a neutral, encyclopedic review of what is known on the topic. It is important to follow " ..
"[[" .. "WP:NPOV" .. "]]" .. " while developing the draft to ensure its appropriateness for use as an article.\n")
elseif p_0_in == mw.text.trim(" BLP ") then
p_0 = mw.text.trim(" This " ..
"[[" .. "WP:Drafts" .. "|" .. "draft" .. "]]" .. " appears to make unsourced or unsufficiently sourced negative statements about a living person, contrary to " ..
"[[" .. "WP:BLP" .. "]]" .. ". It is vital to document such claims with inline citations of " ..
"[[" .. "WP:reliable sources" .. "]]" .. " throughout the process of developing a draft, so that the eventual article will not contain stray unsourced claims.\n")
elseif p_0_in == mw.text.trim(" rename ") then
p_0 = mw.text.trim(" This " ..
"[[" .. "WP:Drafts" .. "|" .. "draft" .. "]]" .. " may need a better name. A draft should be filed under the name of the article it is meant to replace.\n")
elseif p_0_in == mw.text.trim('[TOKEN: DELETE LINE]') then
else p_0 = " This " ..
"[[" .. "WP:Drafts" .. "|" .. "draft" .. "]]" .. " may require cleanup."
end
 -- end parser function translations

return frame:preprocess(
"{{" .. "ombox\n" .. "|" .. " type = content\n| image = \n| imageright = \n| style =\n| textstyle = \n| text = " .. p_0 .. "<includeonly>" ..
"[[" .. "Category:Drafts tagged with cleanup notices" .. "]]" .. "</includeonly>\n| small = " .. (t_small or "") .. " / yes\n| smallimage = none\n| smallimageright = none\n| smalltext = A shorter message body text.\n" .. "}}" .. "<noinclude>\n" ..
"{{" .. "documentation" .. "}}" .. "\n</noinclude>")
end
return p
 ---- end of module ----
-- 0 nowiki segments treated as plain text

Messy example

 ---- beginning of module ----
local p = {}

getArgs = require('Module:Arguments').getArgs

p.main = function(frame)
args = getArgs(frame)

 -- begin variable table
 -- end variable table

 -- begin parser function translations
 -- end parser function translations

return frame:preprocess("#REDIRECT " ..
"[[" .. "Template:Album chart" .. "]]" .. "\n" ..
"{{" .. "R from move" .. "}}")
end
return p
 ---- end of module ----
-- 0 nowiki segments treated as plain text