Template:CodeSample: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
imported>StDoodle
mNo edit summary
Line 1: Line 1:
<noinclude>Uses the named parameters ''title'', ''description'' and ''code'' to display a code block & its information.[[Category:Basic Templates]]</noinclude>
<includeonly>
<includeonly>
{{#if: {{{title|}}}|<h2>{{{title}}}</h2>}}
{{#if: {{{title|}}}|<h2>{{{title}}}</h2>}}
Line 6: Line 5:
{{{code}}}
{{{code}}}
</div></includeonly>
</div></includeonly>
<noinclude>
<p>Uses the named parameters ''title'', ''description'' and ''code'' to display a code block & its information.</p>
<p>Note that only ''code'' is required; the ''title'' and ''description'' are optional.</p>
<p>A sample call to this template:</p>
<pre>
{{CodeSample|
title=Sample Code|
description=Some basic sample code.|
code=
<syntaxhighlight>
int i = 1; //this line is useless!
if (to_int(my_id()) > 1) {
  print("Aw, I guess you aren't Jick.");
}
</syntaxhighlight>
}}
</pre>
<p>Which produces the following:</p>
{{CodeSample|
title=Sample Code|
description=Some basic sample code.|
code=
<syntaxhighlight>
int i = 1; //this line is useless!
if (to_int(my_id()) > 1) {
  print("Aw, I guess you aren't Jick.");
}
</syntaxhighlight>
}}
[[Category:Basic Templates]]</noinclude>

Revision as of 16:26, 28 February 2010


Uses the named parameters title, description and code to display a code block & its information.

Note that only code is required; the title and description are optional.

A sample call to this template:

{{CodeSample|
title=Sample Code|
description=Some basic sample code.|
code=
<syntaxhighlight>
int i = 1; //this line is useless!
if (to_int(my_id()) > 1) {
   print("Aw, I guess you aren't Jick.");
}
</syntaxhighlight>
}}

Which produces the following:

Sample Code

Some basic sample code.

int i = 1; //this line is useless!
if (to_int(my_id()) > 1) {
   print("Aw, I guess you aren't Jick.");
}