WikiDB/Syntax

From TestWiki
< WikiDB
Revision as of 22:32, 7 June 2015 by HappyDog (Talk | contribs) (Data tag: Rewritten to be more of a reference, now that WikiDB/Defining data exists.)

Jump to: navigation, search

This page describes the current syntax for all user input handled by the extension. Note that this is highly likely to change, but I shall endeavour to keep this page up-to-date with the current working version.

Table definitions

Within a DB namespace, the entire page is parsed as follows:

  • All lines that begin with > (as the very first character) are treated as field definitions (see below).
  • The rest of the page will be treated as standard wiki markup.

This means that you can include whatever you like along with your table definition, including images and links and even table data itself!

Field definitions

Each field row has the following syntax, where elements in square brackets are optional and whitespace may be omitted:

> FieldName [: Type [(TypeOptions)]] [LinkDetails] [-- Comment]
  • FieldName - Required - The name of the field. Currently case-sensitive. May contain any characters that don't confuse the syntax (I will fill in the details about this later). Whitespace is trimmed from either end, but internal whitespace is preserved.
  • Type - Optional - One of the defined Types. Must be preceeded by a colon to separate it from the name. If the specified type is not recognised then it is ignored.
  • TypeOptions - Optional. Only valid if Type is defined - A comma-separated list of type options, surrounded in parentheses. The usage varies according to the Type.
  • LinkDetails - Optional - Currently only used for aliases, but will also be used for foreign keys if they get implemented. A standard wiki link to the field name being aliased to, preceeded by #. E.g. use [[#Company name]] to make an alias for 'Company name'.
  • Comment - Optional - A space for you to make notes about the field. Unlike notes elsewhere in the page, this comment is displayed at the top in the main table definition. Starts with two hyphens and runs to the end of the line.

Data tag

See also: WikiDB/Defining data.

Attributes

table
(normally required) Defines the table into which the data will be placed. Required in all situations except when you are defining data on a table definition page, in which case it is optional and will default to the table being defined on that page.
fields
(optional) If present, the tag body is placed into multi-line mode, and this attribute will be treated as a comma-separated list of field names which describe each row of data in the tag body. If omitted, then the tag body will be placed into field/value mode.
separator
(optional) Defines the separator that is used to separate field values in the tag body. Only applies in multi-line mode. If omitted, defaults to a comma. Note that multi-character separators are allowed.
template
(optional) "none" means that no output is generated, "default" means the data is output in a standard tabular format and any other value will be treated as the name of a template that will be used to display the data. If omitted, defaults to "none".

Body

In field/value mode (fields attribute not present), each line is in the following format:

FieldName=Value

Any line without an = sign is ignored, and white-space is ignored.

In mutli-line mode, (fields attribute present) each line is a list of fields, separated by the designated separator character. Blank lines and wiki-style headings are ignored. If a row has fewer fields than are defined in the fields attribute then the remaining fields are left blank. If it has additional fields, then they are ignored.

Repeat tag

This tag allows you to query the data. See WikiDB/Repeat tag syntax for full details.