cc – Template

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix example)
(Rollback to split single-line and multi-line comment)
Line 1: Line 1:
<includeonly>{{#ifeq:{{{1}}}
<includeonly><span style="color: #00F; font-style: italic;"><nowiki>//</nowiki>&nbsp;{{{1}}}</span></includeonly><noinclude>__NOTOC__
|{{#replace:{{{1}}}|<nowiki/>
Displays a one-lined code comment.
<nowiki/>|}}
|<span style="color: #00F; font-style: italic"><nowiki>//</nowiki>&nbsp;{{Trim|{{{1|-no comment defined-}}}}}</span>
|<span style="color: #00F; font-style: italic">/*
{{#ifeq:
{{#replace:{{{1}}}|<nowiki>
</nowiki>|}}|
{{#replace:{{{1}}}|<nowiki/>
<nowiki/> <nowiki/>|}}
|{{Trim|{{{1|-no comment defined-}}}}}
<nowiki/>*/
|<nowiki/>
{{{1|-no comment defined-}}}
<nowiki/>*/}}</span>
}}</includeonly><noinclude>__NOTOC__
Displays a code comment.


== Usage ==
== Usage ==
{| style="float: right; min-width: 50em; max-width: 50%"
<nowiki>{{cc|code comment to display}}</nowiki>
| colspan="4" |
{{Important|
* There is an issue with multiline comments in space-triggered code blocks (see below). Use <tt>&lt;code&gt;</tt> tags instead for multiline comments.
* There is also an issue where leaving a blank line would break the code block (even in <tt>&lt;code&gt;</tt> tags - use <tt>&lt;br&gt;</tt> instead)}}
|-
| style="vertical-align: top" |
spaced
{{cc|test1
test2
test3}}
| style="vertical-align: top" |
spaced + line return
{{cc|
test1
test2


test3}}
== Result ==
| style="vertical-align: top" |
{{cc|test}}
code tag
<code>{{cc|test1
test2
test3}}</code>
| style="vertical-align: top" |
code tag + line return
<code>{{cc|
test1
test2
 
test3}}</code>
|}
{{<nowiki/>cc|'''''message'''''}}
* message: comment to display
 
{| class="wikitable"
|+ Examples
! Code
! Result
|-
| <nowiki>{{cc}}</nowiki>
| {{cc}}
|-
| <nowiki>{{cc|this code is wonderful}}</nowiki>
| {{cc|this code is wonderful}}
|-
|
<pre><code>{{cc|this
code
is
wonderful}}</code></pre>
| <span style="color: #00F; font-style: italic; white-space: pre">/*
this
code
is
wonderful
<nowiki/>*/</span>
|-
|
<pre><code>{{cc|
this
code<br>
is
wonderful
 
}}</code></pre>
| <span style="color: #00F; font-style: italic; white-space: pre">/*
this
code
 
is
wonderful
<nowiki/>*/</span>
|}


== Source ==
== Source ==
<syntaxhighlight lang="html">
<syntaxhighlight lang="html">
<span style="color: #00F; font-style: italic"><nowiki>//</nowiki>&nbsp;{{Trim|{{{1|-no comment defined-}}}}}</span>
<span style="color: #00F; font-style: italic;">//&nbsp;{{{1}}}</span></syntaxhighlight>
</syntaxhighlight>


== See also ==
== See also ==
* [[Template:codecomment]]
* [[Template:codecomment]]
 
* [[Template:ccml]]


[[Category:Templates|{{uc:cc}}]]
[[Category:Templates|{{uc:cc}}]]
</noinclude>
</noinclude>

Revision as of 16:38, 4 December 2020

Displays a one-lined code comment.

Usage

{{cc|code comment to display}}

Result

// test

Source

<span style="color: #00F; font-style: italic;">//&nbsp;{{{1}}}</span>

See also