Extension:TemplateSandbox

From MediaWiki.org
Jump to: navigation, search
This is technical documentation of the extension. There is also a user documentation.
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
TemplateSandbox

Release status:Extension status stable

Screenshot of TemplateSandbox.png
ImplementationTemplate:Extension#type Special page, Page action
DescriptionTemplate:Extension#description Preview pages using sandboxed templates
Author(s)Template:Extension#username Brad Jorsch (Anomietalk)
Latest versionTemplate:Extension#version 1.1.0 (2014-03-29)
MediaWikiTemplate:Extension#mediawiki TemplateSandbox master only supports core's master. For 1.20 and later, use the corresponding REL1_XX branches.
PHPTemplate:Extension#php 5.5+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
ParametersTemplate:Extension#parameters

$wgTemplateSandboxEditNamespaces

Hooks usedTemplate:Extension#hook
AlternateEditPreviewManual:Hooks/AlternateEditPreview
EditPage::importFormDataManual:Hooks/EditPage::importFormData
EditPage::showStandardInputs:optionsManual:Hooks/EditPage::showStandardInputs:options

Translate the TemplateSandbox extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The TemplateSandbox extension adds the ability to preview a page using sandboxed versions of templates, allowing for easy testing before making the sandbox code live. It also works with Scribunto modules.

Installation[edit]

  • Download and place the file(s) in a directory called TemplateSandbox in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
wfLoadExtension( 'TemplateSandbox' );
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing extensions using wfLoadExtension(), since MediaWiki 1.25. If you need to install this extension in earlier versions, instead of wfLoadExtension( 'TemplateSandbox' );, you need to use:

require_once "$IP/extensions/TemplateSandbox/TemplateSandbox.php";

Configuration[edit]

Parameters
  • $wgTemplateSandboxEditNamespaces: Namespaces in which to show the "Preview page with this template" box below the edit form. NS_TEMPLATE by default. Can be expanded to all namespaces by individual users using advancedtemplatesandbox.js.

Usage[edit]

The extension adds a new special page, Special:TemplateSandbox. To preview a page using sandboxed templates, do the following:

  1. Copy the templates to be tested under a common prefix. For example, you might copy Template:Foo to User:Example/sandbox/Template:Foo. Alternatively, you might create User:Example/sandbox/Template:Foo as a redirect to Template:Foo/sandbox.
  2. Go to Special:TemplateSandbox. Fill in the page or revision to be rendered, and the prefix you chose in step 1. It is possible to specify multiple prefixes (a prefix search path) by separating them using vertical bars, e.g. User:Example/sandbox1|User:Example/sandbox2.
  3. Click View.

The extension also adds a box at the bottom of the edit form for pages in the namespaces configured in $wgTemplateSandboxEditNamespaces. This allows for previewing some other page as it would appear were the template being edited saved with the current contents of the edit form.

See also[edit]