Module:If preview/sandbox: Difference between revisions

Content deleted Content added
see if I broke something
continue reducing per YAGNI
Line 4:
main
 
This function returns the either the first argument or second argument passed to
this module, depending on whether it is being previewed.
 
Usage:
Line 11 ⟶ 12:
]]
function p.main(frame)
local preview_moderevision_id = frame:preprocess('{{REVISIONID}}')
if p.boolean(frame) then
-- {{REVISIONID}} is usually the empty string when previewed.
returnif not preview_moderevision_id == nil and not preview_moderevision_id == '' then
return frame.args[1] or ''
else
Line 18 ⟶ 21:
end
 
--[[
pmain
 
This function returns either the first argument or second argument passed to
this module's parent (i.e. template using this module), depending on whether it
is being previewed.
 
Usage:
{{#invoke:If preview|pmain}}
 
]]
 
function p.pmain(frame)
return p.main(frame:getParent())
end
 
--[[
boolean
 
This function returns true when it is a preview and false otherwise
 
Usage:
{{#invoke:If preview|boolean}}
 
]]
 
function p.boolean(frame)
local preview_mode = frame:preprocess('{{REVISIONID}}')
return not preview_mode == nil and not preview_mode == ''
end
return p