Modul:If preview
Videz
![]() | Ta modul je odvisen od zaščite strani. Je zelo viden modul, ki ga uporabljajo številne strani, ali pa je pogosto substituiran. Ker bi vandalizem ali napake vplivale na številne strani in bi lahko celo trivialno urejanje povzročilo veliko obremenitev strežnikov, je zaščiten pred urejanjem. |
![]() | Predloga se uporablja na številnih straneh, zato bo vsaka njena sprememba takoj zelo opazna. Prosimo, da vse spremembe, ki jih želite uvesti, pred uvedbo preizkusite na podstraneh predloge (/peskovnik in /testniprimeri) ali na svojih lastnih podstraneh. Pred spreminjanjem te predloge se o želenih spremembah rajši pogovorite na pogovorni strani. |
![]() | Uporablja Lua: |
![]() | Ta modul uporablja TemplateStyles: |
This module implements {{if preview}} and {{preview warning}}. It helps templates/modules determine if they are being previewed.
Prefer implementing the template versions in other templates.
In a module to use the main()
, you need to pass a frame table with an args table.
For the preview warning, use _warning()
.
Zgornja dokumentacija je vključena iz Modul:If preview/dok. (uredi | zgodovina) Urejevalci lahko preizkušate ta modul v peskovniku (ustvari | mirror) in testnihprimerih (ustvari). Prosimo, da dodate kategorije v /dok podstran. Podstrani te predloge. |
local p = {}
--[[
main
This function returns the either the first argument or second argument passed to this module, depending on whether it is being previewed.
Usage:
{{#invoke:If preview|main|value_if_preview|value_if_not_preview}}
]]
function p.main(frame)
local result = ''
Preview_mode = frame:preprocess('{{REVISIONID}}'); -- use magic word to get revision id
if not (Preview_mode == nil or Preview_mode == '') then -- if there is a value then this is not a preiview
result = frame.args[2] or '';
else
result = frame.args[1] or ''; -- no value (nil or empty string) so this is a preview
end
return result
end
--[[
pmain
This function returns the 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 the either true or false, depending on whether it is being previewed.
Usage:
{{#invoke:If preview|boolean}}
]]
function p.boolean(frame)
local result = ''
Preview_mode = frame:preprocess('{{REVISIONID}}'); -- use magic word to get revision id
if not (Preview_mode == nil or Preview_mode == '') then -- if there is a value then this is not a preiview
result = false;
else
result = true; -- no value (nil or empty string) so this is a preview
end
return result
end
return p