Help:Wiki template: Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
Elf (talk | contribs)
editing for this site
Elf (talk | contribs)
Template definition: example of parameterized template
Line 16: Line 16:
==Template definition==
==Template definition==
To create a template, just create an article titled "Template:nameofyourtemplate"; for example, Template:needswork or Template:plug-in. Whatever  you put into that article then appears whenever you insert the template (as shown in "Template usage") into another article.
To create a template, just create an article titled "Template:nameofyourtemplate"; for example, Template:needswork or Template:plug-in. Whatever  you put into that article then appears whenever you insert the template (as shown in "Template usage") into another article.
For example, perhaps you want the '''plug-in''' template shown above to display text like this:
----
*'''Plug-in name:''' My Plug In
*'''Web site:''' http://www.mycompany.com
*'''Current released version:''' 1.4
----
In this case, the template definition ([[Template:plug-in]]) looks similar to this:
<nowiki>*'''Plug-in name:''' {{{name}}}</nowiki>
<nowiki>*'''Web site:''' {{{web}}}</nowiki>
<nowiki>*'''Current released version:''' {{{version}}}</nowiki>


==Complexities==
==Complexities==

Revision as of 04:26, 14 March 2007

This wiki software allows us to define templates, which are the same concept as macros in some languages.

Overview

A template can define standard text that you'd like to appear in more than one place. For example, you could define a template named needswork that, when inserted into a page, displays text like this:

This page needs more work to make it look good.

Furthermore, templates can have arguments (parameters) that allow you to specify repetitive data in a standard and more easily understandable way. For example, you could define a template named plug-in that provides space for someone to type the basic information about a COLLADA plug-in and then displays the info in a nice format as defined within the template, rather than making the editor do all the work over and over.

Template usage

When editing an article, you see templates like this:

 {{needswork}}

or like this:

  {{plug-in|name=My Plug In|web=http://www.mycompany.com|version=1.4}}

Template definition

To create a template, just create an article titled "Template:nameofyourtemplate"; for example, Template:needswork or Template:plug-in. Whatever you put into that article then appears whenever you insert the template (as shown in "Template usage") into another article.

For example, perhaps you want the plug-in template shown above to display text like this:



In this case, the template definition (Template:plug-in) looks similar to this:

*'''Plug-in name:''' {{{name}}}
*'''Web site:''' {{{web}}}
*'''Current released version:''' {{{version}}}

Complexities

There are additional features that are useful in templates, including

  • Predefined variables that do such things as calculate the name of the current article.
  • Special markup to have things appear only in the template definition page but not where the template occurs, or vice-versa.

These are documented elsewhere; see "External links."

See also

  • Special:Prefixindex where you can select the Template namespace and see the names of all templates that currently exist in this wiki.

External links