Template:ASST/doc

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

This template aids building magic word templates for interactive assistants, by parsing the current page name according to certain assistant-page naming conventions.

Usage[edit]

Call this template within the magic word, specifying a template to pass the parse information to.

  • t — required — the template to which to pass the parse information. Omit prefix Template:.

There are three ways to use a specified name instead of the current page name, using unnamed parameters.

  • Specify the name of a page that is part of an assistant.
  • Specify the name of a global assistant (without the Assistant: prefix).
  • Specify the parent page of a local assistant, and the name of the assistant (without the Assistant: prefix).

The following parameters are passed to t; any other named parameters passed to here are passed through to t via Module:TScope#drop.

  • name — The field of the page name that starts with Assistant:.
  • space — The namespace of the page name; no colon.
  • subpage — The part of the page name after name, if any; no leading slash.
  • full — The entire page name that was parsed.
  • parent — The part of the page name before name, if not Wikinews:. No trailing slash.

This template is designed so it can be substituted (via subst:) as well as transcluded (though this won't help if the template named by parameter t doesn't also support substitution).

Examples[edit]

page name parse information

Wikinews:Assistant:Breadboard

name: Assistant:Breadboard
space: Wikinews
subpage:
full:   Wikinews:Assistant:Breadboard
parent:

Template:Assistant:Dwim/foo/bar

name: Assistant:Dwim
space: Template
subpage: foo/bar
full:   Template:Assistant:Dwim/foo/bar
parent:

Category:Assistant:Dwim/quux/baz

name: Assistant:Dwim
space: Category
subpage: quux/baz
full:   Category:Assistant:Dwim/quux/baz
parent:

User:Pi zero/Assistant:Dwim/fnord

name: Assistant:Dwim
space: User
subpage: fnord
full:   User:Pi zero/Assistant:Dwim/fnord
parent: User:Pi zero

Breadboard

name: Assistant:Breadboard
space: Wikinews
subpage:
full:   Wikinews:Assistant:Breadboard
parent:

Wikinews:Reference desk/query
Citation

name: Assistant:Citation
space: Wikinews
subpage:
full:   Wikinews:Reference desk/query/Assistant:Citation
parent: Wikinews:Reference desk/query

Internals[edit]

Magic word templates that use {{ASST}} cannot call each other, as it would cause {{ASST}} to call itself; however, the client subtemplates t can call each other.

The main template is mostly concerned with figuring out what page name is to be parsed; the page name is then passed to subtemplate {{ASST/parse}}, along with additional information gathered through subtemplate {{ASST/find}}.

With no unnamed parameters, uses the name of the current page. With one unnamed parameter, if it has multiple fields or an Assistant: prefix, it's taken to be the page name, otherwise it's the global assistant name and is used to derive a suitable page name. With two unnamed parameters, the second must be suitable as a local assistant name, and both parameters are used to derive a suitable page name.

The alternative parameter arrangements —where an assistant name is specified instead of a page name— are provided because without them, the magic word templates would not relieve the user of having to continually recreate the assistant-page-naming conventions.

See also[edit]