Jump to content

User:Salix alba/TDSkell

From Wikipedia, the free encyclopedia
Sample user interface for the en:User:Salix alba/TDSkell

A javascript snippet to generate a skeleton TemplateData section for a template. It reads the template code to find all the parameters used by the template.

==Usage1 2 3 4 5 6 7 8 9 11 12 س-ب==

To install include

importScript('User:Salix alba/TDSkell.js');

in Special:MyPage/skin.js.

On templates and user pages a link TD Skeleton will appear in the toolbox on the left sidebar. Clicking the link will open an overlay with a skeleton for the templatedata for the template you are looking at. Copy and paste and click the close box.

It also tries to guess default values, aliases, and whether the parameter is required or not. These may not correct. They are listed after the main skeleton:

Possible defaults and aliases

"1": { "aliases": ["year"], "required": false }
"2": { "aliases": ["month"], "required": false }
"3": { "aliases": ["day"], "required": false }
"year": { "required": true }
"month": { "required": true }
"day": { "required": true }
"df": { "required": false }
"w": { "aliases": ["width"], "required": false }
"width": { "default": "16.66%", "required": false }
"align": { "default": "left", "required": false }
"valign": { "default": "top", "required": false }

How it works

[edit]

A simple regular expression is used to find all parameters used in a template. It looks for patterns like {{{1 or {{{name.

The pattern used is /\{\{\{([^\{\|\}<]+)/g.

Require parameter are tested by looking for {{{name}}}, if a parameter appears with a pipe option {{{name|}}} it will not be considered required. Defaults and aliases are found by examining the text following the pipe.

ToDo

[edit]
[edit]