Jump to content

Template:Dialog/preview/doc

From Wikinews, the free news source you can write!

Usage

[edit]

Placing this template on a dialog page indicates — when viewing the dialog page via dialog action do verb view — that incoming dialog parameter preview should be parsed as wiki markup, and the result displayed in place of each call to this template. The parsed text is template-expanded as if the text were on the page named by dialog parameter subject if provided, otherwise as if the text were on the dialog page (affecting magic words such as {{PAGENAME}}).

Ordinarily, buttons within the preview are disabled. Non-blank optional template parameter live overrides this default for all buttons in this preview. The default can also be overridden for an individual button using an optional template parameter to {{dialog/button}}.

Ordinarily, template parameters in the preview text are not substituted for by incoming dialog parameters. Non-blank dialog parameter local-preview-parameters — which must be specified via {{dialog/init}} since it is local — is taken to be an &-separated list of dialog parameters that if present should be substituted into the preview text.

The preview text cannot set up an operational {{dialog/preview}} or {{dialog/init}}; those templates if called would not have their dialog effects. Dialog fields are initialized with values of incoming dialog parameters regardless of whether the fields occur within a preview.

Internals

[edit]

The dialog facilities deliberately do not, at this writing, provide a fully general way to access a dialog parameter whose name is computed dynamically; as a general design principle, the facilities seek to foster a style of dialog markup where things are succinctly specified using a few broad strokes, and therefore seek to avoid the sort of massively-empowering, fine-scale primitive computational operations that would be desirable in a traditional general-purpose programming language. Although the substitution of dialog parameters for template parameters in the preview text can be simulated via {{dialog/psub}}, computing both the names of the template parameters to be substituted for and the values to be substituted in, there would still be no way to access arbitrary dialog parameters whose names are not hardcoded into the stored dialog page. The use of dialog parameter local-preview-parameters enables the preview to access arbitrary dialog parameters determined at view time, while bringing the dependency out in the open by requiring an explicit declaration via {{dialog/init}}, avoiding gratuitous access by substituting only parameters explicitly whitelisted, and avoiding obfuscated nesting by limiting dependencies to a single level per page applied to an entire text (rather than to some particular parameter buried somewhere in the markup).

See also

[edit]