Difference between revisions of "Template"

From Organic Design wiki
(parameters, structure and time, link to Foundation Ontology)
(Change source-code blocks to standard format)
 
Line 14: Line 14:
 
== MediaWiki templates ==
 
== MediaWiki templates ==
 
Templates are basically just normal articles except that they're expected to be embedded within other articles instead of being viewed as a separate page like a normal article. Because of their role as being a general piece of content to be embedded in other articles it becomes useful to be able to specify various particular information which is specific to that specific context it's appearing in, for example we have a template called [[Template:Note]] which is a light-bulb icon in a styled message box, which would be embedded as follows:
 
Templates are basically just normal articles except that they're expected to be embedded within other articles instead of being viewed as a separate page like a normal article. Because of their role as being a general piece of content to be embedded in other articles it becomes useful to be able to specify various particular information which is specific to that specific context it's appearing in, for example we have a template called [[Template:Note]] which is a light-bulb icon in a styled message box, which would be embedded as follows:
{{code|<pre>
+
<source>
 
{{Note
 
{{Note
 
  | text = Hello!
 
  | text = Hello!
 
}}
 
}}
</pre>}}
+
</source>
 
This embeds the [[Template:Note]] article at the location this syntax is used, and it passes one parameter called "text" which contains the actual message which will differ in all the places the template's used. The template article (Template:Note) contains the wikitext to render the styled table with the light-bulb icon, and then specifies where the passes "text" parameter should be placed by using a triple-brace expression, <tt><nowiki>{{{text}}}</nowiki></tt>. Here is what the result looks like:
 
This embeds the [[Template:Note]] article at the location this syntax is used, and it passes one parameter called "text" which contains the actual message which will differ in all the places the template's used. The template article (Template:Note) contains the wikitext to render the styled table with the light-bulb icon, and then specifies where the passes "text" parameter should be placed by using a triple-brace expression, <tt><nowiki>{{{text}}}</nowiki></tt>. Here is what the result looks like:
 
{{Note|Hello!
 
{{Note|Hello!

Latest revision as of 18:11, 22 May 2015

Glossary.svg This page describes a concept which is part of our glossary

A template is a kind of prototype capturing commonly performed operations which can then be referred by a unique name and refined for specific use. Template documents are commonly used in most organisations for contracts and invoices since they have a large portion of there content which is identical for all of them. Some examples are forms or questionnaires.

On the web templates are used where ever specific content is found within the same frame or context, for example an "error message template" for a website might contain all the design and layout for a box and icon that should surround error messages when they need to be displayed. Widgets are also a kind of template, but contain more sophisticated applicational content than a basic design template or form.

Parameters

Templates can exhibit content which is dependent on the context its being used within. For example with the error message template mentioned above, its exclamation-mark icon might render as a red colour if the textual content of the message contains the word "fatal", but otherwise be yellow. Or the widget may be a clock which accounts for the timezone local to the geographic location it's being used within.

Structure

More generally a template can be thought of as a tree structure of other content. The hierarchical aspect is due to the content being able to be in the form of other templates with parameters.

Adding the concept of time to templates

In our Foundation Ontology we define a time oriented aspect by including the concepts of events, queues and workflows.

MediaWiki templates

Templates are basically just normal articles except that they're expected to be embedded within other articles instead of being viewed as a separate page like a normal article. Because of their role as being a general piece of content to be embedded in other articles it becomes useful to be able to specify various particular information which is specific to that specific context it's appearing in, for example we have a template called Template:Note which is a light-bulb icon in a styled message box, which would be embedded as follows:

{{Note
 | text = Hello!
}}

This embeds the Template:Note article at the location this syntax is used, and it passes one parameter called "text" which contains the actual message which will differ in all the places the template's used. The template article (Template:Note) contains the wikitext to render the styled table with the light-bulb icon, and then specifies where the passes "text" parameter should be placed by using a triple-brace expression, {{{text}}}. Here is what the result looks like:

Note.svg Note: Hello!


In wiki organisation, templates are used in a more specific way relating to forms and queries, see templates, forms and queries for more detail.

See also