قالب:Templating/Y

من بيضيبيديا، الموسوعة الفارغة
(بالتحويل من Templating/Y)
اذهب إلى التنقل اذهب إلى البحث

{{#css: div#bodyContent div#YT a, div#bodyContent div#YT a:link, div#bodyContent div#YT a:visited { color: #CACACA !important;} div#bodyContent div#YT a:hover, div#bodyContent div#YT a:active { color: whitesmoke !important;} html body div#bodyContent div#YT .YTmenu td{padding: 7px 0 7px 8px;vertical-align:top;} html body div#bodyContent div#YT .YTmenu td b{text-align:right;display:block;color:#766C59;margin-left:-1px;} html body div#bodyContent div#YT .YTmenu a{display:block;padding: 12px 20px 8px 0;clear:left; } html body div#bodyContent div#YT .YTmenu li span{display: block; width: 28px; text-align: right; } html body div#bodyContent div#YT .YTmenu tr:hover{background: #525252;} html body div#bodyContent div#YT .YTmenu tr:hover b{color: #F64C4C;} div#bodyContent div#YT .YTmenu { overflow:auto; height:280px; background:#333;float:right; max-width: 200px;line-height: 1.3em;} div#bodyContent div#YT .right { background:#111; list-style:none;float:right; max-width: 200px;} }}


Templating/Logo

Welcome to Aunt Jemima's Templating Academy!

Your comprehensive guide to Templates on Uncyclopedia.


{{#css: div#bodyContent div#TA a, div#bodyContent div#TA a:link, div#bodyContent div#TA a:visited { color: saddlebrown !important;text-shadow: #aaa -1px 1px 3px !important; } html body div#bodyContent div#TA a:hover, html body div#bodyContent div#TA a:active { color: maroon !important; text-decoration: none !important; text-shadow: #aaa -1px 1px 3px !important; }

}}


Loops Functions

 {{#switch: {{Get}}
 |0=Apple
 |1=Pear
 |2=Orange
 }}
 
This is just an example, so if you wanted it to output 'Orange' you'd make a link like {{Goto|2|Oranges are great}} (and the 'Oranges are great' part is just text) or something, and then it'd output 'Orange' because you set the input value to 2 using the Goto template. Just look at the source for this page and it should explain it I think.

Apples are awesome

Pears are cool


#while[عدل المصدر]

{{#while}} performs a loop (i.e. it repeatedly parses a given wiki markup block statement) so long as the condition mark-up evaluates to non-whitespace.

{{
  #while:
  | <condition text>
  | <block statement>
}}
Examples

Note: The following examples use the VariablesExtension.

The wiki markup:

{{ #vardefine: i | 0 }}{{
  #while:
  | {{ #ifexpr: {{ #var: i }} < 5 | true }}
  |<nowiki/>
* {{ #var: i }}{{ #vardefine: i | {{ #expr: {{ #var: i }} + 1 }} }}
}}

produces the following:

  • 0
  • 1
  • 2
  • 3
  • 4

{{#while}} can also be used in a template to simulate a numbered array. If the page "Template:Loops Test" contains

{{
  #vardefine: i | 0
}}{{
  #while:
  | {{{ arg{{#var: i }} |}}}
  |<nowiki/>
* {{{ arg{{#var: i }} }}}{{
    #vardefine: i
    | {{ #expr: {{ #var: i }} + 1 }}
  }}
}}

then the wiki-markup

{{Loops Test
|arg0=zero
|arg1=one
|arg2=two
|arg3=three
|arg4=four
}}

produces

  • zero
  • one
  • two
  • three
  • four

It's important to note that whitespace, including newlines, tabs, and spaces, is stripped from the beginning and end of all the arguments of these parser functions. If this is not desirable, adding any non-whitespace characters (including the HTML encoding for a whitespace character &#32;) will prevent further stripping (hence the <nowiki/> tags in the above examples).

#dowhile[عدل المصدر]

{{#dowhile}} performs exactly like {{#while}}, with the exception that the block statement is guaranteed to be parsed and displayed (if it results in displayable text) at least once. This is done before the condition text is evaluated.

#loop[عدل المصدر]

{{
  #loop: <variable name>
  | <starting value>
  | <number of loops to be performed>
  | <wiki markup>
}}

{{#loop}} repeatedly parses and displays <wiki markup> a number of times equal to the absolute value of <number of loops to be performed>. <Starting value> is placed in a variable (accessible by VariablesExtension's {{#var:}} parser function) using the name <variable name>. After each loop, the variable is incremented by one if <number of loops to be performed> is positive, or decremented by one if <number of loops to be performed> is negative.

Note: From all loop functions, #loop should have the best performance since there is no condition which has to be expanded and validated for each cycle.

Examples

The following code:

{{#loop: varname
  | 4
  | 4
  | <nowiki/>
* This is round {{#var:varname}} and we have {{#expr: 7- {{#var:varname}}}} more to go
}}

produces

  • This is round 4 and we have 3 more to go
  • This is round 5 and we have 2 more to go
  • This is round 6 and we have 1 more to go
  • This is round 7 and we have 0 more to go

Oranges are great

Working...[عدل المصدر]