Module:If preview/sandbox: Difference between revisions

Content deleted Content added
is this all it takes
poke
Line 7:
 
]]
local function is_preview(frame)
local revision_id = mw.getCurrentFrame()frame:preprocess('{{REVISIONID}}')
-- {{REVISIONID}} is usually the empty string when previewed.
-- I don't know why we're checking for nil but hey, maybe someday things
-- not (Preview_mode == nil or Preview_mode == '')
-- returnwould nothave broken
return (revision_id == nil or revision_id == '')
return revision_id, type(revision_id), tostring(revision_id == nil or revision_id == '')
end
 
Line 26:
]]
function p.if_preview(frame)
if is_preview(frame) then
return frame.args[1] or ''
else
Line 34:
 
--[[
warning
preview_warning
 
This function returns a "preview warning", which is the first argument marked
Line 44:
]]
function p.warning(frame)
-- if not is_preview(frame) then return '' end
local warning = frame.args[1]:match('^%s*(.-)%s*$') or ''
Line 54:
return mw.ustring.format(
'%s<div class="preview-warning"><strong>Preview warning "%s" %s %s:</strong> %s</div>',
frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Preview warning/styles.css' }
},
rev_id,
rev_id_type,
eval,
warning
)