Module:If preview: Difference between revisions
m
8 revisions imported from wikipedia:Module:If_preview
m (Changed protection level for "Module:If preview": High-risk Lua module ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))) |
m (8 revisions imported from wikipedia:Module:If_preview) |
||
(One intermediate revision by one other user not shown) | |||
Line 1:
local p = {}
local cfg = mw.loadData('Module:If preview/configuration')
--[[
main
This function returns
this module, depending on whether the page is being previewed.
]]
function p.main(frame)
if cfg.preview then
▲ result = frame.args[2] or '';
else
end
end
Line 25 ⟶ 21:
pmain
This function returns
this module's parent (i.e. template using this module), depending on whether it
is being previewed.
]]
function p.pmain(frame)
return p.main(frame:getParent())
local function warning_text(warning)
return mw.ustring.format(
cfg.warning_infrastructure,
cfg.templatestyles,
warning
)▼
end
local warning = args[1] and args[1]:match('^%s*(.-)%s*$') or ''
if warning == '' then
return warning_text(cfg.missing_warning)
end
if not cfg.preview then return '' end
return warning_text(warning)
end
--[[
warning
This function returns
up with HTML and some supporting text, depending on whether the page is being previewed.
disabled since we'll implement the template version in general
]]
--function p.warning(frame)
-- return p._warning(frame.args)
--end
--[[
▲function p.boolean(frame)
warning, but for pass-through templates like {{preview warning}}
]]
function p.pwarning(frame)
return p._warning(frame:getParent().args)
▲ end
end
return p
|