cc – Template

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix tip)
(Remove codecomment dependency, Add Category:cc template usage error categorisation)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#ifeq:{{{1}}}
<includeonly><span class="code-comment">//&nbsp;{{Trim|{{{1|-no comment defined-{{TemplateCase||[[Category:cc template usage error]]}}}}}}}</span></includeonly><noinclude>{{Doc/Template
|{{#replace:{{{1}}}|<nowiki/>
|descr= Displays a one-lined code comment. See {{Template|codecomment}} for multi-lines comments. It also adds the page to the [[:Category:cc template usage error|cc template usage error]] category on usage error.
<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 ==
|param1= message
{| style="float: right; min-width: 50em; max-width: 50%"
|descr1= comment to display
| 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}}
|example1= <nowiki>{{cc}}</nowiki>
| style="vertical-align: top" |
|result1= {{cc}}
code tag
<code>{{cc|test1
test2
test3}}</code>
| style="vertical-align: top" |
code tag + line return
<code>{{cc|
test1
test2


test3}}</code>
|example2= <nowiki>{{cc|this code is wonderful}}</nowiki>
|}
|result2= {{cc|this code is wonderful}}
{{<nowiki/>cc|'''''message'''''}}
* message: comment to display


{| class="wikitable"
|example3= <div style="white-space: pre"><nowiki>{{cc|this
|+ Examples
! Code
! Result
|-
| <nowiki>{{cc}}</nowiki>
| {{cc}}
|-
| <nowiki>{{cc|this code is wonderful}}</nowiki>
| {{cc|this code is wonderful}}
|-
|
<pre><code>{{cc|this
code
code
is
is
wonderful}}</code></pre>
wonderful}}</nowiki></div>
| <span style="color: #00F; font-style: italic; white-space: pre">/*
|result3= {{cc|this
this
code
code
is
is
wonderful
wonderful}}
<nowiki/>*/</span>
}}</noinclude>
|-
|
<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>
|}
 
== Source ==
<syntaxhighlight lang="html">
<span style="color: #00F; font-style: italic"><nowiki>//</nowiki>&nbsp;{{Trim|{{{1|-no comment defined-}}}}}</span>
</syntaxhighlight>
 
== See also ==
* [[Template:codecomment]]
 
 
[[Category:Templates|{{uc:cc}}]]
</noinclude>

Latest revision as of 15:56, 30 June 2022

Displays a one-lined code comment. See {{codecomment}} for multi-lines comments. It also adds the page to the cc template usage error category on usage error.

This template is used on these pages.

Usage

{{cc|message}}

  • message: comment to display
Examples
Code Result
{{cc}} // -no comment defined-
{{cc|this code is wonderful}} // this code is wonderful
{{cc|this code is wonderful}}
// this

code is wonderful