Difference between revisions of "Module:Preview warning"

From blackwiki
Jump to navigation Jump to search
blackwiki>Jc86035
 
blackwiki>Jc86035
m
Line 1: Line 1:
 
local p = {}
 
local p = {}
 
local function trim(s)
 
return s:match('^%s*(.-)%s*$')
 
end
 
  
 
function p.main(frame)
 
function p.main(frame)

Revision as of 10:57, 23 April 2017

Usage

Put this code in your template. The message will only show in Show preview (you can try with this page):

  • {{#invoke:Preview warning|main|Message text}}



local p = {}

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