විකිපීඩියා:Wrapper templates
මෙම පිටුව ඉංග්රීසි ව්යාපෘතියෙන් මෙහි ගෙනවිත් ඇත. අන්තර්ගතය අපගේ ව්යාපෘතිය සමඟ 100% නොගැලපෙනමුත් අපගේ අවශ්යතාවයන් වලට අනුකූලව ගොඩනගා ගැනීම සඳහා මූලික පියවර ලෙස භාවිතා කළ හැකිය. |
මෙම උදවු පිටුව කෙලෙසද-මාර්ගෝපදේශනයකි. මෙය විකිපීඩියාවේ ප්රතිමාන සහ ක්රියාමාර්ගවල සමහර ලක්ෂණ විස්තර කරයි. එය විකිපීඩියාවේ ප්රතිපත්ති සහ මාර්ගෝපදේශන අතුරින් එකක් නොවේ, and may reflect varying levels of consensus and vetting. මෙම පිටුව තුල කිසිවක් අසංගත නම් එම ප්රතිපත්ති සහ මාර්ගෝපදේශන වෙත යොමු වන්න |
Wrapper templates are outer templates which wrap around simpler inner templates, to greatly extend the basic functionality of the inner templates. The concept is to structure the underlying, inner templates to be used as utility tools by various outer, wrapper templates. Templates can be wrapped to existing templates with Module:Template wrapper.
Experience has shown that, when the underlying templates have been restructured with a full set of options to be used, then numerous variations of wrapper templates have been created to extend template functionality with a broad variety of new features.
Wrapper templates can be useful for consolidation, as they allow templates to build off of each other, whereas copying and pasting templates can make them harder to maintain.
A simple example
[සංස්කරණය]The function of Template:Exams is to place a box on one's userpage stating that one is taking a wikibreak to focus on exams. A more general template for wikibreaks, Template:Wikibreak, already exists, so rather than duplicating it, {{Exams}} just consists of a call of {{Wikibreak}} with some parameters specified, such as an image of books rather than the default image of a sunset.
An example with substitution
[සංස්කරණය]Template:Don't ping inserts a message on a talk page that one is following the page and doesn't need to be pinged in replies. It calls Template:Please ping with the no
parameter specified. This gets a little trickier because {{Don't ping}} may be substituted. To address this, the actual code used is {{safesubst:<noinclude/>Please ping|no}}
.
Wrappers around Lua modules
[සංස්කරණය]Many templates, such as {{if empty}} or {{infobox}}, are just simple wrappers around Lua modules, in this case Module:If empty and Module:Infobox. This is straightforward to implement as the frame:getParent().args
table in Lua, which is accessed from the module, can directly read the arguments passed to the wrapper template. The template can then be as simple as {{#invoke:If empty|main}}
(although there is slightly more code to make it substable and add documentation). Two of the main points of this are to avoid needing the "{{#invoke:" syntax in articles, and backward compatibility.
Templates
[සංස්කරණය]- {{uses infobox person}}
- {{wrapper}}
- {{wraps infobox}}
- {{CS1 wrapper}}