Template:Example: Difference between revisions

From Rosetta Code
Content added Content deleted
(Add a couple of usage examples for this template. Also, hopefully fix whatever is breaking additional headers.)
(test: remove the SMW sets. Will temporarily add them to the three example pages manually. Perhaps SMW is screwing things up when it sees the set function calls inside an embedded page.)
Line 1: Line 1:
{{#set:example of={{{task}}}}}{{#set:implemented in language={{#if:{{{langpage|}}}|{{{langpage}}}|{{{language}}}}}}}{{#if: {{{langpage|}}} | <span id="{{{language}}}">[[:Category:{{{language}}}|{{{langpage}}}]]</span> | [[:Category:{{{language}}}|{{{language}}}]] }}<noinclude><br/>
{{#if: {{{langpage|}}} | <span id="{{{language}}}">[[:Category:{{{language}}}|{{{langpage}}}]]</span> | [[:Category:{{{language}}}|{{{language}}}]] }}<noinclude><br/>
Sets up an example page
Sets up an example page
{|
{|
Line 21: Line 21:
<nowiki>=={{example|task=Hough transform|language=C#|langpage=C_sharp}}==</nowiki>
<nowiki>=={{example|task=Hough transform|language=C#|langpage=C_sharp}}==</nowiki>
{{template}}</noinclude>
{{template}}</noinclude>

Unfortunately, the header markup needs to be in the page that uses the template, rather than the template itself. Otherwise, you won't see edit links.

Revision as of 21:58, 19 August 2010

[[:Category:{{{language}}}|{{{language}}}]]
Sets up an example page

param name meaning
task The name of the task this is an example of
language The name of the language this example is implemented in
langpage (optional) The pagename of the language, if different (for example: C_sharp for C#)

For example, when adding an example of the Hough transform implemented in C++, you would put this at the top of your example page: =={{example|task=Hough transform|language=C++}}==

If you are adding an example in a language that needs a special page title, such as C#, you would put this at the top of your example page: =={{example|task=Hough transform|language=C#|langpage=C_sharp}}==


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

Unfortunately, the header markup needs to be in the page that uses the template, rather than the template itself. Otherwise, you won't see edit links.