Jump to content

Modulo:If preview

Permanente a nasalakniban a modulo
Manipud iti Wikipedia, ti nawaya nga ensiklopedia
Daytoy ket daan a rebision iti daytoy a panid, kas inurnos babaen ni Lam-ang (tungtungan | aramid) idi 15:57, 26 Pebrero 2020 (Kinopia manipud iti Module:If preview/921781789). Ti agdama nga adres ket permanente a silpo iti daytoy a bersion, ken mabalin nga adu ti pakaigiddiatanna manipud iti agdama a rebision.
(dip) ← Nadadaan a rebision | Kaudian a rebision (dip) | Nabarbaro a rebision → (dip)
Dokumentasion ti modulo

Isayangkat daytoy a modulo ti {{if preview}} ken {{preview warning}}. Tumulong a mangikeddeng no maipadpadas dagiti plantilia/modulo.

Nasysayaat a maisayangkat dagiti bersion ti plantilia kadagiti sabali a plantilia.

Iti maysa a modulo usaren ti main(), nasken nga ipasa ti tabla ti kuadro nga agraman iti maysa nga tabla ti argumento.

Para iti ballaag ti panagipadas, mabalin nga usaren ti _warning().

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