Template:Template journal/doc: Difference between revisions
(Created page with "{{Documentation subpage}} {{Uses TemplateStyles|Template:Template journal/styles.css}} {{Support|Template:Template journal/arg}} {{tsh|tj}} The {{tl|Template journal}} template allows to showcase with colors and multiple lines the syntax of any template, while providing an easy way to display placeholder texts using colons as separators. For an identical template that displays the output in horizontal format, see {{tl|Template journal inline}}. == Usage == ;Syntax :{{...") |
mNo edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Documentation subpage}} | {{Documentation subpage}} | ||
{{lua|Module:Params}} | |||
{{Support|Template:Template journal/arg}} | |||
{{Uses TemplateStyles|Template:Template journal/styles.css}} | {{Uses TemplateStyles|Template:Template journal/styles.css}} | ||
{{tsh|tj}} | {{tsh|tj}} | ||
The {{tl|Template journal}} template allows to showcase with colors and multiple lines the syntax of any template, while providing an easy way to display placeholder texts using colons as separators. For an identical template that displays the output in horizontal format, see {{tl|Template journal inline}}. | The {{tl|Template journal}} template allows to showcase with colors and multiple lines the syntax of any template, while providing an easy way to display placeholder texts using colons as separators. For an identical template that displays the output in horizontal format, see {{tl|Template journal inline}}. | ||
== | == Syntax == | ||
{{tji|tj|template|param. name 1: param. content 1|param. name 2: param. content 2...}} | |||
For instance, the following code | For instance, the following code | ||
{{Pre|{{{{tcp|tj}}|cite book | |||
|last: Author's last name|first: Author's first name | |last: Author's last name|first: Author's first name | ||
|author-link: Author's page name on Wikipedia|date: Publication date | |author-link: Author's page name on Wikipedia|date: Publication date | ||
|title: Work's title|url: Work's URL|location: Where the work was published | |title: Work's title|url: Work's URL|location: Where the work was published | ||
|publisher: Name of the publisher}} | |publisher: Name of the publisher}} }} | ||
will produce the following result. | will produce the following result. | ||
Line 29: | Line 28: | ||
Likewise, the following code | Likewise, the following code | ||
{{Pre|{{{{tcp|tj}}|Infobox movie quote|name:|image:|caption:|character:|actor:|writer: | |||
|firstusedin:|alsousedin:|moviequotes:}} | |firstusedin:|alsousedin:|moviequotes:}} }} | ||
will produce the following result. | will produce the following result. | ||
Line 39: | Line 38: | ||
And finally, the following code | And finally, the following code | ||
{{Pre|{{{{tcp|tj}}|Blockquote | |||
| Cry "Havoc" and let slip the dogs of war. | | Cry "Havoc" and let slip the dogs of war. | ||
| <nowiki>[[William Shakespeare]]</nowiki> | | <nowiki>[[William Shakespeare]]</nowiki> | ||
Line 45: | Line 44: | ||
| title: <nowiki>''[[Julius Caesar (play)|Julius Caesar]]''</nowiki> | | title: <nowiki>''[[Julius Caesar (play)|Julius Caesar]]''</nowiki> | ||
| source: act III, scene I | | source: act III, scene I | ||
}} | }} }} | ||
will produce the following result. | will produce the following result. | ||
Line 56: | Line 55: | ||
| source: act III, scene I | | source: act III, scene I | ||
}} | }} | ||
=== Edge cases === | === Edge cases === | ||
To preserve one or more initial colons from being replaced, the <code>&#58;</code> wikitext entity must be used. After one colon has been replaced all other colons in the argument will be preserved. | To preserve one or more initial colons from being replaced, the <code>&#58;</code> wikitext entity must be used. After one colon has been replaced all other colons in the argument will be preserved. | ||
Line 67: | Line 63: | ||
Thus, the following are all valid parameters, | Thus, the following are all valid parameters, | ||
< | {{Pre|<nowiki><!-- Good example --></nowiki> | ||
{{tj|Some template | {{{{tcp|tj}}|Some template | ||
| Hello | | Hello | ||
| World | | World | ||
Line 78: | Line 74: | ||
| ink :marble | | ink :marble | ||
| book: /books?id{{=}}mAlLt1aGsWYC | | book: /books?id{{=}}mAlLt1aGsWYC | ||
}} | }} }} | ||
and they will produce the following result. | and they will produce the following result. | ||
Line 95: | Line 91: | ||
Arguments containing one or more unescaped equals signs will be silently ignored. An unescaped leading colon will be treated as a normal character, exactly like any other colon that might follow in the same parameter. Thus, the following code | Arguments containing one or more unescaped equals signs will be silently ignored. An unescaped leading colon will be treated as a normal character, exactly like any other colon that might follow in the same parameter. Thus, the following code | ||
< | {{Pre|<nowiki><!-- Bad example --></nowiki> | ||
{{tj|Some template | {{{{tcp|tj}}|Some template | ||
| Hello | | Hello | ||
| this = will = be = ignored | | this = will = be = ignored | ||
| road: unknown | | road: unknown | ||
| :windmill: true | | :windmill: true | ||
}} | }} }} | ||
will produce the following problematic result. | will produce the following problematic result. | ||
Line 115: | Line 111: | ||
Instead, the right way to write the previous unlikely example is the following, | Instead, the right way to write the previous unlikely example is the following, | ||
< | {{Pre|<nowiki><!-- Good example --></nowiki> | ||
{{tj|Some template | {{{{tcp|tj}}|Some template | ||
| Hello | | Hello | ||
| this {{=}} will {{=}} not {{=}} be {{=}} ignored | | this {{=}} will {{=}} not {{=}} be {{=}} ignored | ||
| road: unknown | | road: unknown | ||
| :windmill: true | | :windmill: true | ||
}} | }} }} | ||
which will correctly print | which will correctly print | ||
Line 140: | Line 136: | ||
<includeonly>{{sandbox other||{{testcases other|| | <includeonly>{{sandbox other||{{testcases other|| | ||
<!-- Categories below this line, please --> | <!-- Categories below this line, please --> | ||
[[Category:Documentation formatting templates]] | [[Category:Documentation formatting templates]] | ||
}}}}</includeonly> | }}}}</includeonly> |
Latest revision as of 04:38, 20 August 2023
It contains usage information, categories and other content that is not part of the original template page.
|
This template uses Lua: |
Supporting Templates |
This template uses TemplateStyles: |
The {{Template journal}} template allows to showcase with colors and multiple lines the syntax of any template, while providing an easy way to display placeholder texts using colons as separators. For an identical template that displays the output in horizontal format, see {{Template journal inline}}.
Syntax
{{tj
For instance, the following code
{{tj|cite book
|last: Author's last name|first: Author's first name
|author-link: Author's page name on Wikipedia|date: Publication date
|title: Work's title|url: Work's URL|location: Where the work was published
|publisher: Name of the publisher}}
will produce the following result.
| last = Author's last name
| first = Author's first name
| author-link = Author's page name on Wikipedia
| date = Publication date
| title = Work's title
| url = Work's URL
| location = Where the work was published
| publisher = Name of the publisher
}}
Likewise, the following code
{{tj|Infobox movie quote|name:|image:|caption:|character:|actor:|writer:
|firstusedin:|alsousedin:|moviequotes:}}
will produce the following result.
| name =
| image =
| caption =
| character =
| actor =
| writer =
| firstusedin =
| alsousedin =
| moviequotes =
}}
And finally, the following code
{{tj|Blockquote
| Cry "Havoc" and let slip the dogs of war.
| [[William Shakespeare]]
| character: Mark Antony
| title: ''[[Julius Caesar (play)|Julius Caesar]]''
| source: act III, scene I
}}
will produce the following result.
| Cry "Havoc" and let slip the dogs of war.
| [[William Shakespeare]]
| character = Mark Antony
| title = ''[[Julius Caesar (play)|Julius Caesar]]''
| source = act III, scene I
}}
Edge cases
To preserve one or more initial colons from being replaced, the :
wikitext entity must be used. After one colon has been replaced all other colons in the argument will be preserved.
Similarly, to insert one or more equals signs into a parameter content, either {{=}}
or =
must be used.
Thus, the following are all valid parameters,
<!-- Good example -->
{{tj|Some template
| Hello
| World
| foo: bar
|
| road:
| keep:the:colon:I:said:keep:it!
| ink :marble
| book: /books?id=mAlLt1aGsWYC
}}
and they will produce the following result.
| Hello
| World
| foo = bar
|
| road =
| keep:the:colon = I:said:keep:it!
| ink = marble
| book = /books?id=mAlLt1aGsWYC
}}
Arguments containing one or more unescaped equals signs will be silently ignored. An unescaped leading colon will be treated as a normal character, exactly like any other colon that might follow in the same parameter. Thus, the following code
<!-- Bad example -->
{{tj|Some template
| Hello
| this = will = be = ignored
| road: unknown
| :windmill: true
}}
will produce the following problematic result.
Instead, the right way to write the previous unlikely example is the following,
<!-- Good example -->
{{tj|Some template
| Hello
| this = will = not = be = ignored
| road: unknown
| :windmill: true
}}
which will correctly print
By design, there is no way to deviate from the format of one argument per line (vertical format). If you need to display a template and all its arguments in one single line (horizontal format), please refer to {{tji}}. If you need a more irregular output, please refer to other solutions.
See also
- {{Template journal inline}}
- {{Template link}}