User:Inductiveload/Template autoloader

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

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

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

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

Improvements

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 = 
...
}}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.