Jump to content

Template:Dialog/init

From Wikinews, the free news source you can write!
[edit] Template documentation

Usage

Use this template on a page to be accessed via dialog action do to specify initial values for one or more dialog fields. For a single field, specify thus:

{{dialog/init|name|value}}

This causes value to be processed through template-expansion, and the resulting value to be associated with dialog field name, as if it had been provided as an incoming dialog parameter, and overriding any dialog parameter name provided. This bypasses the ordinary processing by which the wiki software converts the output of template-expansion into html for viewing; the ordinary processing rearranges whitespace, linebreaks, and markup for list items, indentation, italics, wikilinks, and so on. Some, but not all, of the ordinary processing can be avoided by means of {{dialog/safe}}.

Ordinarily, the template call itself expands to the empty string. However, a non-blank third parameter causes the template call to expand to value.

The template call must appear on the accessed page itself, as it is processed by the do action before template-expansion of the page as a whole. This enhances security since arbitrary templates used on the dialog page cannot indirectly override dialog parameter values.

The value may contain template parameters processed by the do action (such as SUBJECT-CONTENT, or incoming dialog parameters), as the action replaces those before processing calls to {{dialog/init}}. Because those template parameters are processed before {{dialog/init}} calls, they depend on incoming dialog parameters only, regardless of value or of any other call to {{dialog/init}}. The specified value will, however, override any incoming dialog parameter to determine the initial content of a dialog field called name.

Reserved parameter names — anything that starts with an upper-case letter and does not contain any lower-case letters — cannot be overridden using {{dialog/init}}; any attempt to do so is ignored.

The number of calls to this template should be minimized, as processing each of them may entail a separate communication across the internet to the wiki server (though the dialog software will save itself the trouble if it notices value doesn't contain any template calls). As of this writing, only up to eight calls to this template are processed by action do; any additional calls do not affect dialog fields. Multiple dialog fields can be handled in a single call to this template by using a compound definiend: The first template parameter is a list of one or more field names, delimited by parentheses and separated by whitespace, and the second template parameter should template-expand to a Wikilisp-style list of string literals. The names are bound to the values represented by the string literals.

If a parameter provided through {{dialog/init}} is meant to be explicitly passed by a button (rather than implicitly passed by delegation), there has to be a dialog field on the page with the name of that parameter (typically declared using {{dialog/textarea|hidden=1}}); explicit button parameters are always taken from dialog fields, not from incoming dialog parameters.

Technical restrictions

The value must not contain any unmatched braces ({ or }) and must not have braces nested more than 32 deep (as of this writing). The unbalanced-braces problem can be avoided by using {{(*}} and {{*)}}. If these limtations are exceeded, the template call does not affect dialog fields (because the dialog software fails to recognize it in the raw wiki markup).

See also