Module:If preview/sandbox: Difference between revisions

Content deleted Content added
add pmain back
does this work?
Line 1:
local p = {}
 
local is_preview = mw.loadData('Module:Preview warning/is preview')
--[[
is_preview
Line 20 ⟶ 21:
This function returns either the first argument or second argument passed to
this module, depending on whether the page is being previewed.
 
Usage:
{{#invoke:If preview|main|value_if_preview|value_if_not_preview}}
 
]]
function p.main(frame)
if is_preview(frame) then
return frame.args[1] or ''
else
Line 39 ⟶ 37:
this module's parent (i.e. template using this module), depending on whether it
is being previewed.
 
Usage:
{{#invoke:If preview|pmain}}
 
]]
Line 53 ⟶ 48:
This function returns a "preview warning", which is the first argument marked
up with HTML and some supporting text, depending on whether the page is being previewed.
 
Usage:
{{#invoke:If preview|warning|preview_warning_text}}
 
]]
function p.warning(frame)
if not is_preview(frame) then return '' end
local warning = frame.args[1]:match('^%s*(.-)%s*$') or ''