Jump to content

User:Inductiveload/Template autoloader

From Wikipedia, the free encyclopedia

The template autoloader is a script that will insert a blank template into the page your are edit, so you don't need to retype the parameters or have to remember the parameter names and orders.

How to install

[edit]

Copy the following to your JS:

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:pathoschild/templatescript.js]]
 */
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add({
		name: 'Autoload template',
		scriptUrl: 'User:Inductiveload/Template autoloader.js',
		script: function() { autoloadTemplate(); }
	})
});

How to use

[edit]

When you are editing a page, click the "Autoload template" link in the sidebar toolbox. This will prompt you to enter the name of a template. The script will them prepend a blank template to the article you are editing.

Conditions

[edit]
  • There is a blank template example wrapped in <pre id="autoload">{{example| p1 = ...}}</pre> on the page Template:Example/doc

Improvements

[edit]

I am happy with this script as it is. If you want to extend it or improve it, feel free. Please drop a link here, as I'd like to see it! Suggestions for improvement:

  • Allow more than one autoload template per template, so you can have variants for different purposes.
  • Allow the template to be wrapped by a template, so what you write on the template documentaion pages is something like:
{{autoload template|name=name (pending suggestion above)|
{{example
 | parameter1 = 
...
}}