مواد ڏانھن هلو

ماڊيول:If preview

کليل ڄاڻ چيڪلي، وڪيپيڊيا مان

Documentation for this module may be created atماڊيول:If preview/doc

localp={}

localcfg=mw.loadData('Module:If preview/configuration')

--[[
main

This function returns either the first argument or second argument passed to
this module, depending on whether the page is being previewed.

]]
functionp.main(frame)
ifcfg.previewthen
returnframe.args[1]or''
else
returnframe.args[2]or''
end
end

--[[
pmain

This function returns 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.

]]
functionp.pmain(frame)
returnp.main(frame:getParent())
end


localfunctionwarning_text(warning)
returnmw.ustring.format(
cfg.warning_infrastructure,
cfg.templatestyles,
warning
)
end

functionp._warning(args)

localwarning=args[1]andargs[1]:match('^%s*(.-)%s*$')or''
ifwarning==''then
returnwarning_text(cfg.missing_warning)
end

ifnotcfg.previewthenreturn''end

returnwarning_text(warning)
end

--[[
warning

This function returns a "preview warning", which is the first argument marked
up with HTML and some supporting text, depending on whether the page is being previewed.

disabled since we'll implement the template version in general

]]
--function p.warning(frame)
-- return p._warning(frame.args)
--end

--[[
warning, but for pass-through templates like {{preview warning}}
]]
functionp.pwarning(frame)
returnp._warning(frame:getParent().args)
end

returnp