Template:Out: Difference between revisions

From Rosetta Code
Content added Content deleted
(add two optional parameters "in" and "comment", and properly document the template)
m (typo)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><div>
<includeonly><div>
;{{#if: {{{1|}}} | {{{1}}} | Output}}{{#if: {{{comment|}}}{{{in|}}} | <span style="font-weight:normal> &nbsp; &mdash;&nbsp; {{#if: {{{comment|}}} | {{{comment|}}} | when given an input of <code>{{{in|}}}</code>}}</span> |}}<nowiki>:</nowiki></div></includeonly><noinclude>
;{{#if: {{{1|}}} | {{{1}}} | Output}}{{#if: {{{note|}}} | <i style="font-weight:normal> ({{{note}}})</i> |}}{{#if: {{{case|}}}{{{input|}}} | <span style="font-weight:normal> &nbsp;&mdash;&nbsp; {{{case|for input <code>{{{input|}}}</code>}}}</span> |}}{{#if: {{{text|}}} | <nowiki/> <span style="font-weight:normal>{{{text}}}</span> | <nowiki>:</nowiki>}}</div></includeonly><noinclude>


This template is used to introduce the example output of a programming example.
This template is used to introduce the output of a programming example.


===Usage===
===Usage===
Line 23: Line 23:
|-
|-
| <code>1</code>
| <code>1</code>
| Replaces the word "Output".
| Text to show instead of the word "Output".
| <code><nowiki>{{out|Return value}}</nowiki></code>
| <code><nowiki>{{out|Return value}}</nowiki></code>
| {{out|Return value}}
| <div style="white-space:nowrap">{{out|Return value}}</div>
|-
|-
| <code>in</code>
| <code>case</code>
| The test-case/condition which produces this output.
| <code><nowiki>{{out|case=test case 3}}</nowiki></code>
| <div style="white-space:nowrap">{{out|case=test case 3}}</div>
|-
| <code>input</code>
| The (single-line) input which produces this output.
| The (single-line) input which produces this output.
| <code><nowiki>{{out|in=Hello world}}</nowiki></code>
| <code><nowiki>{{out|input=Hello world}}</nowiki></code>
| {{out|in=Hello world}}
| <div style="white-space:nowrap">{{out|input=Hello world}}</div>
|-
|-
| <code>comment</code>
| <code>note</code>
| A remark to show in parentheses.
| Any other text you want shown in the same line.
| <code><nowiki>{{out|comment=test case 1}}}}</nowiki></code>
| <code><nowiki>{{out|note=elided}}</nowiki></code>
| <div style="white-space:nowrap">{{out|comment=test case 1}}</div>
| <div style="white-space:nowrap">{{out|note=elided}}</div>
|-
| <code>text</code>
| Free-form text to follow instead of a colon.
| <code><nowiki>{{out|text=...}}</nowiki></code>
| <div style="white-space:nowrap">{{out|text=...}}</div>
|}
|}

You can combine multiple parameters, except that <tt>case</tt> and <tt>input</tt> are mutually exclusive.

{{template}}</noinclude>
{{template}}</noinclude>

Latest revision as of 10:34, 27 August 2016


This template is used to introduce the output of a programming example.

Usage

Write {{out}} just above the <pre>...</pre> block that lists a code example's output.

It also accepts these optional parameters:

Parameter Purpose Example Renders as
{{out}}
Output:
1 Text to show instead of the word "Output". {{out|Return value}}
Return value:
case The test-case/condition which produces this output. {{out|case=test case 3}}
Output  —  test case 3:
input The (single-line) input which produces this output. {{out|input=Hello world}}
Output  —  for input Hello world:
note A remark to show in parentheses. {{out|note=elided}}
Output (elided):
text Free-form text to follow instead of a colon. {{out|text=...}}
Output ...

You can combine multiple parameters, except that case and input are mutually exclusive.



This is a template. There are many others. See Category:RCTemplates for a complete list of templates.