Difference between revisions of "Module:Preview warning"

From Northumberland Climbing
Jump to navigation Jump to search
climbing>Jo-Jo Eumerus
m (Protected "Module:Preview warning": High-risk Lua module: Per WP:RFPP request ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)))
 
m (1 revision imported)
 
(No difference)

Latest revision as of 10:44, 13 August 2020

Documentation for this module may be created at Module:Preview warning/doc

local p = {}

--[[
main

This function returns parameter 1 as a warning if the page containing it is being previewed.

Usage:
{{#invoke:Preview warning|main|warning_text}}

]]

function p.main(frame)
	local preview = frame.args[1]:match('^%s*(.-)%s*$') or ''
	if preview == '' then preview = 'Something is wrong with this template' end
	if frame:preprocess( "{{REVISIONID}}" ) == "" then return '<div class="hatnote" style="color:red"><strong>Warning:</strong> ' .. preview .. ' (this message is shown only in preview)</div>' end
end

return p