Module:If preview/configuration

From Viki
Jump to navigation Jump to search

Documentation for this module may be created at Module:If preview/configuration/doc

 1 --[[
 2 We perform the actual check for whether this is a preview here since
 3 preprocessing is relatively expensive.
 4 ]]
 5 local frame = mw.getCurrentFrame()
 6 
 7 local function is_preview()
 8 	local revision_id = frame:preprocess('{{REVISIONID}}')
 9 	-- {{REVISIONID}} is usually the empty string when previewed.
10 	-- I don't know why we're checking for nil but hey, maybe someday things
11 	-- would have broken
12 	return revision_id == nil or revision_id == ''
13 end
14 
15 local function templatestyles()
16 	return frame:extensionTag{
17 		name = 'templatestyles', args = { src = 'Module:If preview/styles.css' }
18 	}
19 end
20 
21 return {
22 	preview = is_preview(),
23 	templatestyles = templatestyles(),
24 	warning_infrastructure = '%s<div class="preview-warning"><strong>Preview warning:</strong> %s</div>',
25 	missing_warning = 'The template has no warning text. Please add a warning.'
26 }