DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:wst

Wikimedia Style Templates

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" yes
  • 2016-06-26 "Elenor Of Tsort" yes
  • 2015-08-10 "Detritus" unknown
  • 2014-09-29 "Hrun" unknown

plugin Wikimedia-style templates

Last updated on
2017-07-08
Provides
Syntax
Repository
Source

This plugin provides a syntax for WikiMedia-style templates.

Installation

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

If you install this plugin manually, make sure it is installed in lib/plugins/wst. It might not work if the directory is called differently.

Examples/Usage

Let's assume that we need to add the same fragment to many articles, something like “The main article for this section is [link]”. In order to automate this task, we'll create a template that would accept the link destination and generate the desired text with proper formatting.

Let's also assume that the default namespace for our templates is set to “template” (you can check your settings in “Admin→Configuration Settings”).

Minimal example

First, we create a new page called “template:main” with the following contents:

template:main
//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//

Now go to the desired article and insert the following code:

{{wst>main|Article_name}}

where “Article_name” is the page that your link will point to. After you save it, you will get:

The main article for this section is Article_name.

Includeonly tag

The template in the minimal example works fine, but our “template:main” page looks ugly:

The main article for this section is {{{1}}}.

Let's change the template so that the desired text appears on other pages (where the template code {{wst>main|}} is inserted), but is hidden from the template page itself. We will wrap the code between <includeonly> and </includeonly> tags, as follows:

template:main
<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly>

Now the template page looks empty, although it contains the template code.

Noinclude tag

Instead of showing the ugly template code (and instead of showing an empty page), let's add some text that would appear on the template page, but not on pages where the code {{wst>main|}} is inserted. We will wrap this text between <noinclude> and </noinclude> tags, as follows:

template:main
<noinclude>Plugin syntax: {{wst>main|Article_name}}</noinlcude>
 
<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly>

Template complete with documentation

When creating a template, it would be nice to also create a documentation for the users. One way to create documentation is to create another template, say “main_doc” or “main/doc”. The documentation template will only show the template syntax and the resulting text.

template:main_doc
====== Documentation: main ======
<noinclude><< [[template:main|Main]]</noinclude>
===== Syntax =====
<nowiki>{{wst>main|Article_name}}</nowiki>
===== Output =====
//Main article for this section is **[[category:article|Article_name]]**.//
template:main
<noinclude>{{wst>main_doc}}</noinclude>
 
<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly>

Syntax

A basic syntax for templates created with WST plugin is:

{{wst>template_name|argument_1|argument_2}}

where:

  • the template code is always wrapped between double curled brackets;
  • wst> is common for all templates;
  • template_name is the name of a page in wst namespace (default is “template:”);
  • argument_1, argument_2 etc. are arguments to the template code separated by a vertical line.

Named and numbered parameters

By default, each argument can be referred by its ordinal number, i.e. {{{1}}} refers to the first argument, {{{2}}} to the second etc. It is possible to explicitly specify the number of the argument:

{{wst>template_name|1 = argument_1|2 = argument_2}}

In this notation, the actual order of arguments does not matter any more.

Besides this, arguments can be referred to by a name. For example, in the following code

{{wst>template_name|a = argument}}

the parameter can be referred to by {{{a}}}.

Tags

  • <noinclude>...</noinclude> – the text will be displayed on a page (e.g. a template page), but will not be shown on pages that call the template.
  • <includeonly>...</includeonly> – the text will be displayed only on pages that call a template, but not on a template page itself.

Configuration and Settings

The only setting available is “Default namespace for Wikimedia-style templates”, which defaults to “template”. Leaving the default value should be OK for most installations. If this namespace is already used by another template, just provide another value.

Development

[downloadable blocks, development comments]

Change Log

[preferable GitHub RSS feed or similar]

  • 2017-04-17
    • Initial release

Known Bugs and Issues

[this section might not be needed in case of external bug manager, or use RSS feed]

ToDo/Wish List

[developers roadmap]

FAQ

[discussions should ideally be deleted and turned into FAQ entries along the way]

Discussion

Could be placed on an external page (e.g. plugin:pluginname:discussion) to have a distinction between user comments and author docs

plugin/wst.txt · Last modified: 2017-09-20 10:39 by ciubotaru