Wersije pśirownaś

Using Templates

Wersija 6465:

Wersija 6465 wót wužywarja Verdi

Wersija 6467:

Wersija 6467 wót wužywarja Verdi

Klucowe słowa:

Zespominanje pytańskich wuslědkow:

How to use Templates
How to use Templates

Wopśimjeśe:

The SUMO Knowledge Base includes a new feature called '''Templates'''. Templates are similar to old features like "dymanic content" but are more powerful and flexible. __TOC__ == What are Templates == Templates are a way of reusing small pieces of content. Instead of writing a message twice, you can create and update it in one place, and then refer to it in other pages. The other pages will stay up-to-date with changes to the Template automatically! A Template is just a special wiki page whose name starts with "Template:". It has all the features of a wiki page: it can be localized, it has a history, it understands wiki markup. ==How to make a Template== {note}A list of existing Templates can be found [https://support.mozilla.com/en-US/kb/category/60 here].{/note} #[https://support.mozilla.com/en-US/kb/new Create a new KB article] #Make sure the name begins with "Template:" - For example, [https://support.mozilla.com/en-US/kb/Template:aboutconfig Template:aboutconfig] #Set the Category to "Template" #Continue writing the Template the same way you would any other Knowledge Base article. == How to include a Template in an Article == To use a template in a wiki page, all you have to do is "link" to the template. For example: <nowiki>[[Template:Some Template]]</nowiki> or <nowiki>[[T:Some Template]]</nowiki> Instead of creating a link, the content of '''Template:Some Template''' will be included into the current page. Any wiki markup in the template will be rendered. == Using arguments with a Template == Templates support passing in arguments, to let you reuse content that is ''almost'' the same. Say, for example, you had a standard notice that told users that a document only applied to Firefox 4, and another version that said it only applied to Firefox 3.6. The text of those notices might be identical except for the Firefox version: a perfect time to use a template! '''Template:OnlyVersionX''': {<!-- -->note}This document or section only applies to <nowiki>'''Firefox {{{1}}}'''</nowiki>!{<!-- -->/note} Then, in one wiki page, you could do this: <nowiki>[[Template:OnlyVersionX|4]]</nowiki> And in another page, you could do: <nowiki>[[Template:OnlyVersionX|3.6]]</nowiki> You can use multiple arguments, or the same argument twice, too! '''Template:XLikesY''': <pre><nowiki># {{{2}}} likes {{{1}}}. # {{{3}}} likes {{{2}}}. # Class! Nobody likes {{{2}}}!</nowiki></pre> Then to use it: <nowiki>[[Template:XLikesY|Lisa|Milhouse|Janey]]</nowiki> This would result in: <blockquote> # Milhouse likes Lisa. # Janey likes Milhouse. # Class! Nobody likes Milhouse! </blockquote> Keeping track of all those numbers can get confusing, so you can also ''name'' arguments to a template: '''Template:XPrecededY''': First comes {{{first}}}, then comes {{{second}}}. And using it: <nowiki>[[Template:XPrecededY|first=love|second=marriage]]</nowiki> With named arguments, you don't need to worry about the order when you use the template: <nowiki>[[Template:XPrecededY|second=marriage|first=love]]</nowiki> Both examples of using '''Template:XPrecededY''' will have the same result.
Templates are a way of reusing small pieces of content. Instead of writing a message twice, you can create and update it in one place, and then refer to it in other pages. The other pages will stay up-to-date with changes to the Template automatically! __TOC__ == What are Templates == A Template is just a special wiki page whose name starts with "Template:". It has all the features of a wiki page: it can be localized, it has a history, it understands wiki markup. ==How to make a Template== {note}A list of existing Templates can be found [https://support.mozilla.com/en-US/kb/category/60 here].{/note} #[https://support.mozilla.com/en-US/kb/new Create a new KB article] #Make sure the name begins with "Template:" - For example, [https://support.mozilla.com/en-US/kb/Template:aboutconfig Template:aboutconfig] #Set the Category to "Template" #Continue writing the Template the same way you would any other Knowledge Base article. == How to include a Template in an Article == To use a template in a wiki page, all you have to do is "link" to the template. For example: <nowiki>[[Template:Some Template]]</nowiki> or <nowiki>[[T:Some Template]]</nowiki> Instead of creating a link, the content of '''Template:Some Template''' will be included into the current page. Any wiki markup in the template will be rendered. == Using arguments with a Template == Templates support passing in arguments, to let you reuse content that is ''almost'' the same. Say, for example, you had a standard notice that told users that a document only applied to Firefox 4, and another version that said it only applied to Firefox 3.6. The text of those notices might be identical except for the Firefox version: a perfect time to use a template! '''Template:OnlyVersionX''': {<!-- -->note}This document or section only applies to <nowiki>'''Firefox {{{1}}}'''</nowiki>!{<!-- -->/note} Then, in one wiki page, you could do this: <nowiki>[[Template:OnlyVersionX|4]]</nowiki> And in another page, you could do: <nowiki>[[Template:OnlyVersionX|3.6]]</nowiki> You can use multiple arguments, or the same argument twice, too! '''Template:XLikesY''': <pre><nowiki># {{{2}}} likes {{{1}}}. # {{{3}}} likes {{{2}}}. # Class! Nobody likes {{{2}}}!</nowiki></pre> Then to use it: <nowiki>[[Template:XLikesY|Lisa|Milhouse|Janey]]</nowiki> This would result in: <blockquote> # Milhouse likes Lisa. # Janey likes Milhouse. # Class! Nobody likes Milhouse! </blockquote> Keeping track of all those numbers can get confusing, so you can also ''name'' arguments to a template: '''Template:XPrecededY''': First comes {{{first}}}, then comes {{{second}}}. And using it: <nowiki>[[Template:XPrecededY|first=love|second=marriage]]</nowiki> With named arguments, you don't need to worry about the order when you use the template: <nowiki>[[Template:XPrecededY|second=marriage|first=love]]</nowiki> Both examples of using '''Template:XPrecededY''' will have the same result.

Slědk k historiji