Mô tổ:If preview
Vẻ ngoài
![文档图示](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Test_Template_Info-Icon_-_Version_%282%29.svg/50px-Test_Template_Info-Icon_-_Version_%282%29.svg.png)
![]() | Này mô khối sử dụngLua ngôn ngữ: |
![]() | Bổn mô khối sử dụng dướiKhuôn mẫu hình thức: |
Kể trênHồ sơKhảm nhậpTựModule:If preview/doc.(Biên tập|Lịch sử) Người biên tập có thể ở bổn mô khối hộp cát(Sáng tạo|Cảnh trong gương)Cùng thí nghiệm dạng lệ(Sáng tạo)Giao diện tiến hành thực nghiệm. Bổn mô khối tử giao diện. |
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