PreloadTemplates

PreloadTemplates allows users to insert a premade syntax from a list of selectable templates directly within the source editor.
== ==
== ==
The script can be used as it is, but it does also support these customizable variables that can be added before the import on Common.js. Common.js will run before MediaWiki:ImportJS.
Variable 	 	Default value 	Type 	 	
preloadTemplates_list 	Set the page name (namespace included) with the list of templates to be preloaded.	MediaWiki:Custom-PreloadTemplates	string	 	
{| class="mw-collapsed mw-collapsible" style="margin: 0; text-align: center; width: 100%;"	
{| class="mw-collapsed mw-collapsible" style="margin: 0; text-align: center; width: 100%;"	MediaWiki:Custom-PreloadTemplates	string	Example:	Example:
preloadTemplates_list = "MediaWiki:Custom-PreloadTemplatesList";	 	 	 	 	
== ==
=== Requirements ===
To use the tool, you have to create the required pages:
* MediaWiki:Custom-PreloadTemplates (or whatever you set as your template list).
** You will add here the list of the templates you want to preload from the editor. Everything in a wikitext bulleted list (the list made by *) will be treated as a template name. Everything else will be treated as normal text.
** You may also add a display title to by using a pipe (|) after the template name, similarly to how the wiki navigation works.
* For each template you listed, you have to create the subpage /preload (or whatever you set as your subpage).
** Here you will add the text that you want to be preloaded as it is when the template is selected.
** If you choose to have a case-by-case preload page, then the full path must be used on the template lists. With a case-by-case preload, it's possible to have multiple preload pages for a single template.
** The default namespace is the "Template:" namespace, this can be changed by setting the preloadTemplates_namespace option to your desired namespace.
Both kind of pages support the use of <noinclude></noinclude> and <includeonly></includeonly> tags.
== ==
=== Default ===
Using the default configuration if on MediaWiki:Custom-PreloadTemplates we add:
With this code, clicking on any of the template listed there will add the text stored on the subpage, for example Template:Template 1/preload. The template will be listed with the display title indicated after the pipe, if added.
=== Custom ===
By using these options:
preloadTemplates_list = "MediaWiki:Custom-PreloadTemplatesList";
preloadTemplates_subpage = "case-by-case";
preloadTemplates_namespace = "Template";
The template list will be retrieved from MediaWiki:Custom-PreloadTemplatesList. On that page, using this code:
Will create a list using the display titles after the pipe character which will preload the page indicated before the pipe.
=== Tags in preload page ===
On the preload page of a template, if we use:
When the template will be preloaded only the following code will be added to the editor:
If you want to preload noinclude/includeonly tags (for example, if you want to add a category), you can do so by using a trick like this:
<noinc<includeonly/>lude>
</noinc<includeonly/>lude>
which will result in:
<noinclude>
</noinclude>
once preloaded.