Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
MainPage
Community portal
Recent changes
Random page
Help
Special pages
Donate
Search
Search
English
Appearance
Log in
Request account
Personal tools
Log in
Request account
Export translations
Translate
English
Language statistics
Message group statistics
Export
Tools
Tools
move to sidebar
hide
Actions
Language statistics
Message group statistics
Export
General
Printable version
In other projects
Appearance
move to sidebar
hide
Settings
Group
Category:Maintenance
Help:Blocking users
Help:Bots
Help:Categories
Help:Contents
Help:Deletion and undeletion
Help:Diff
Help:Editing pages
Help:ExpandTemplates
Help:Extension:ParserFunctions
Help:External searches
Help:Formatting
Help:Images
Help:Links
Help:Magic words
Help:Managing files
Help:Moving a page
Help:Namespaces
Help:Navigation
Help:Parser functions in templates
Help:Patrolled edits
Help:Preferences
Help:Protected pages
Help:Random page
Help:Random root page
Help:Range blocks
Help:Recent changes
Help:Redirects
Help:Skins
Help:Special pages
Help:Starting a new page
Help:Substitution
Help:System message
Help:Tables
Help:Talk pages
Help:TemplateData
Help:Templates
Help:TemplateStyles
Help:Tracking changes
Help:Undelete
Help:User contributions
Help:Watchlist
Help:What links here
Manual:Expr parser function syntax
Manual:Extending wiki markup
Manual:Hooks
Manual:Magic words
Manual:Messages API
Manual:Parser functions
Module:Arguments/doc
Module:Int/doc
Module:Message box/configuration/doc
Module:Message box/doc
Module:Template translation/doc
Module:Transcluder/doc
Module:Version/doc
Module:Yesno/doc
News
Parser extension tags
Parser function extensions
Project:Language policy
Template:Admin tip
Template:Advanced user manual
Template:Anontools
Template:ApiEx
Template:Autocat
Template:Auxiliary template common notice
Template:Branching
Template:Bugfix
Template:Bugzilla
Template:Button
Template:Candidate
Template:Caution
Template:Clarify
Template:Collapse top
Template:Component
Template:Deprecated-inline
Template:Description missing
Template:Distinguish
Template:Documentation
Template:Documentation subpage
Template:Done
Template:EmptyCatGood
Template:Escape template list
Template:Excerpt
Template:Extension development
Template:Fixtext
Template:For
Template:Further
Template:Help
Template:High-risk
Template:Historical
Template:I18n navigation
Template:In progress
Template:Intricate template
Template:Introduced-inline
Template:IRC
Template:Localized link
Template:Localized link/messagedoc
Template:Magic words
Template:Main
Template:MainPage
Template:Markup
Template:Markup/row
Template:Mbox templates
Template:Module rating
Template:Move
Template:MW version
Template:MW version/layout
Template:N/a
Template:Navbar
Template:Newarticletext
Template:No
Template:Not done
Template:Note
Template:Optional
Template:Parser functions nav
Template:Partially done
Template:PD Help Page
Template:Phabricator
Template:Ptag
Template:Purge
Template:Recentchangestext
Template:Removed-inline
Template:Required
Template:Rev
Template:Security
Template:See
Template:See also
Template:Sp-contributions-footer
Template:Sp-contributions-footer-anon
Template:Special page
Template:Template shortcut
Template:Template test cases notice
Template:TemplateData header
Template:Thankyou
Template:To do
Template:Tracked
Template:Translatable
Template:Translatable template name
Template:Unusedtemplatestext
Template:Update
Template:Used in system
Template:Watchlists navigation
Template:Why
Template:WikiNonStop News
Template:Yes
TemplateData
Language
aa - Afar
aae - Arbëresh
ab - Abkhazian
abr - Abron
abs - Ambonese Malay
ace - Acehnese
acf - Saint Lucian Creole
acm - Iraqi Arabic
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
aig - Antiguan and Barbudan Creole English
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
ann - Obolo
anp - Angika
apc - Levantine Arabic
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
ban-bali - Balinese (Balinese script)
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bci - Baoulé
bcl - Central Bikol
bdr - West Coast Bajau
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bew - Betawi
bg - Bulgarian
bgc - Haryanvi
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
blk - Pa'O
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Rinconada Bikol
bug - Buginese
bug-bugi - Buginese (Buginese script)
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
ccp - Chakma
cdo - Mindong
cdo-hant - Mindong (Traditional Han script)
cdo-latn - Mindong (Latin script)
ce - Chechen
ceb - Cebuano
ch - Chamorro
chn - Chinook Jargon
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cop - Coptic
cps - Capiznon
cpx - Puxian
cpx-hans - Puxian (Simplified Han script)
cpx-hant - Puxian (Traditional Han script)
cpx-latn - Puxian (Latin script)
cr - Cree
crh - Crimean Tatar
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
crh-ro - Dobrujan Tatar
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
dag - Dagbani
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
dga - Southern Dagaare
din - Dinka
diq - Dimli
dlg - Dolgan
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dua - Duala
dv - Divehi
dz - Dzongkha
ee - Ewe
efi - Efik
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - Spanish (formal address)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
fat - Fanti
ff - Fula
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fon - Fon
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fvr - Fur
fy - Western Frisian
ga - Irish
gaa - Ga
gag - Gagauz
gan - Gan
gan-hans - Gan (Simplified Han script)
gan-hant - Gan (Traditional Han script)
gcf - Guadeloupean Creole
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
gld - Nanai
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
gpe - Ghanaian Pidgin
grc - Ancient Greek
gsw - Alemannic
gu - Gujarati
guc - Wayuu
gur - Frafra
guw - Gun
gv - Manx
ha - Hausa
hak - Hakka Chinese
hak-hans - Hakka (Simplified Han script)
hak-hant - Hakka (Traditional Han script)
hak-latn - Hakka (Latin script)
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
hke - Hunde
hno - Northern Hindko
ho - Hiri Motu
hoc-latn - Ho (Latin script)
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
hsn - Xiang
ht - Haitian Creole
hu - Hungarian
hu-formal - Hungarian (formal address)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
iba - Iban
ibb - Ibibio
id - Indonesian
ie - Interlingue
ig - Igbo
igl - Igala
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
isv-cyrl - Interslavic (Cyrillic script)
isv-latn - Interslavic (Latin script)
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kai - Karekare
kaj - Jju
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kcg - Tyap
kea - Kabuverdianu
kg - Kongo
kge - Komering
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjh - Khakas
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
knc - Central Kanuri
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ksw - S'gaw Karen
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kus - Kusaal
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
ljp - Lampung Api
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lua - Luba-Lulua
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mad - Madurese
mag - Magahi
mai - Maithili
map-bms - Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Māori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mnc - Manchu
mnc-latn - Manchu (Latin script)
mnc-mong - Manchu (Mongolian script)
mni - Manipuri
mnw - Mon
mo - Moldovan
mos - Mossi
mr - Marathi
mrh - Mara
mrj - Western Mari
ms - Malay
ms-arab - Malay (Jawi script)
mt - Maltese
mui - Musi
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nahuatl
nan - Minnan
nan-hant - Minnan (Traditional Han script)
nan-latn-pehoeji - Minnan (Pe̍h-ōe-jī)
nan-latn-tailo - Minnan (Tâi-lô)
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
nia - Nias
nit - Southeastern Kolami
niu - Niuean
nl - Dutch
nl-informal - Dutch (informal address)
nmz - Nawdm
nn - Norwegian Nynorsk
no - Norwegian
nod - Northern Thai
nog - Nogai
nov - Novial
nqo - N’Ko
nr - South Ndebele
nrm - Norman
nso - Northern Sotho
nup - Nupe
nv - Navajo
ny - Nyanja
nyn - Nyankole
nyo - Nyoro
nys - Nyungar
oc - Occitan
ojb - Northwestern Ojibwa
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pap-aw - Papiamento (Aruba)
pcd - Picard
pcm - Nigerian Pidgin
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Pitcairn-Norfolk
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
pwn - Paiwan
qqq - Message documentation
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rki - Arakanese
rm - Romansh
rmc - Carpathian Romani
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
rsk - Pannonian Rusyn
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rut - Rutul
rw - Kinyarwanda
ryu - Okinawan
sa - Sanskrit
sah - Yakut
sas - Sasak
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
se-fi - Northern Sami (Finland)
se-no - Northern Sami (Norway)
se-se - Northern Sami (Sweden)
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
sh-cyrl - Serbo-Croatian (Cyrillic script)
sh-latn - Serbo-Croatian (Latin script)
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy - Shawiya
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sjd - Kildin Sami
sje - Pite Sami
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sms - Skolt Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
sro - Campidanese Sardinian
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - Siberian Tatar
su - Sundanese
sv - Swedish
sw - Swahili
syl - Sylheti
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Atayal
tcy - Tulu
tdd - Tai Nuea
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tig - Tigre
tk - Turkmen
tl - Tagalog
tly - Talysh
tly-cyrl - Talysh (Cyrillic script)
tn - Tswana
to - Tongan
tok - Toki Pona
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
ttj - Tooro
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vmw - Makhuwa
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
wal - Wolaytta
war - Waray
wls - Wallisian
wlx - Wali
wo - Wolof
wuu - Wu
wuu-hans - Wu (Simplified Han script)
wuu-hant - Wu (Traditional Han script)
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yrl - Nheengatu
yua - Yucatec Maya
yue - Cantonese
yue-hans - Cantonese (Simplified Han script)
yue-hant - Cantonese (Traditional Han script)
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zgh-latn - Standard Moroccan Tamazight (Latin script)
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
Format
Export for off-line translation
Export in native format
Export in CSV format
Fetch
<languages/> {{PD Help Page}} {{anchor|What is TemplateData?}} <span lang="en" dir="ltr" class="mw-content-ltr">'''{{ll|Extension:TemplateData|TemplateData}}''' is an extension that stores information and parameters associated with a [[Special:MyLanguage/Help:Templates|wikitext template]] and makes it available to an editing interface that can retrieve and present it in a template editor -- all of which helps users add and edit templates on pages.</span> It also provides a user interface for {{ll|Help:TemplateData/Template discovery|discovering templates}}. <span lang="en" dir="ltr" class="mw-content-ltr">As of April 2019, template data functionality is part of the default user experience for all users on all Wikimedia wikis when they add a template, even unregistered users.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Both the default source and visual editors incorporate it in some way, as do many scripts, tools and gadgets.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If you want this functionality on your own wiki, install {{ll|Extension:TemplateData}}.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Adding template data to a template for this extension to use involves inserting a small, simple block of [[w:JSON|JSON]] (explained below) into the template's documentation page.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can do this manually or with the template data editor, a graphical user interface you can access on a template's <code>{{int|vector-view-edit}}</code>/<code>{{int|visualeditor-ca-editsource}}</code> pages on wikis with the TemplateData extension installed.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The JSON contains a list of the template's parameters and information about those parameters and about the template as a whole (see below for details).</span> <span lang="en" dir="ltr" class="mw-content-ltr">Templates that contain template data will display this information in the user interface when a user adds the template.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In some cases, it will change how the editor behaves when you use it to edit or insert a given template, making it much easier for users to perform the steps needed to add a given template.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> == History == </div> <span lang="en" dir="ltr" class="mw-content-ltr">Template data was originally developed in early 2013 with {{ll|VisualEditor|VisualEditor}} in mind, which was in MediaWiki testing stages at the time.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The visual editor is the main visual editing interface for Wikimedia wikis, and template data allows it to have a more useful interface when adding templates.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It was officially supported by the visual editor [[Special:MyLanguage/VisualEditor/Portal/TemplateData|immediately]].</span> <span lang="en" dir="ltr" class="mw-content-ltr">As the visual editor was rolled out to the various major Wikimedia wikis as a default feature from 2013 through 2016, template data became a part of them as well.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In December 2016, the visual editor interface was made available for editing source code as a beta feature.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This was termed the {{ll|2017 wikitext editor}}.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This brought the features of template data to source editing for the first time.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In March 2018, [[User:Samwilson|Sam Wilson]] developed {{ll|Extension:TemplateWizard|nsp=0}}, a GUI template editor extension for the default Wikimedia source editor, {{ll|WikiEditor}} (otherwise known as the 2010 wikitext editor), designed to make the process of adding templates easier by using information from template data.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In [[w:Wikipedia:Wikipedia Signpost/2019-04-30/Technology report|April 2019]], TemplateWizard was made a default part of the 2010 wikitext editor on all Wikimedia wikis.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This meant that template data was now a default part of both the visual editor and the source editor on Wikimedia wikis.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> == Adding or editing template data == </div> <div lang="en" dir="ltr" class="mw-content-ltr"> To add or edit template data, first navigate to a template's page, located at "/Template:''Templatename''". </div> {{anchor|Prior checks}} <div lang="en" dir="ltr" class="mw-content-ltr"> === Checking the current state === </div> <span lang="en" dir="ltr" class="mw-content-ltr">Before adding or editing template data, check whether the template has a '''documentation subpage'''.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Then check whether the template '''already contains template data''' and, if so, whether it's located on the template page or the documentation subpage.</span> {{Note|1=<span lang="en" dir="ltr" class="mw-content-ltr">Be sure to check whether a subpage exists.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If you add template data to a template's main page while a subpage exists with template data, the template data in the main page will override the data on the subpage.</span>|2=warn}} <div lang="en" dir="ltr" class="mw-content-ltr"> ==== Documentation subpages ==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> There are two main ways templates on most Wikimedia wikis store their usage notes and other data that shouldn't be included in the actual template itself, like categories the template should be contained in: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * The vast majority of templates keep usage notes and other data that doesn't belong on the template page itself on a documentation subpage: "/Template:''Templatename''/doc". </div> <span lang="en" dir="ltr" class="mw-content-ltr">On pages like this, the {{((}}{{ll|Template:Documentation|Documentation}}{{))}} template [[Special:MyLanguage/Help:Transclusion|transcludes]] all the /doc page's content onto the template page, keeping the template's source code much cleaner.</span> ** <span lang="en" dir="ltr" class="mw-content-ltr">On templates with documentation subpages, the "[[File:Test Template Info-Icon - Version (2).svg|50px]] '''Template documentation'''" heading will be followed by links such as [view], [edit], [history] and [purge].</span> <div lang="en" dir="ltr" class="mw-content-ltr"> * A few template pages have retained that information on the template's main page. </div> <span lang="en" dir="ltr" class="mw-content-ltr">You can spot it on these pages by looking for an occurrence of <code><nowiki>{{Documentation|content=</nowiki></code> between {{tag|noinclude|open}} tags.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Different wikis may present all this differently.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Rarely, main template pages may still contain documentation even when you've checked all of the foregoing;</span> <span lang="en" dir="ltr" class="mw-content-ltr">here, a user will have added a custom /doc page title between "<code><nowiki>{{Documentation|</nowiki></code>" and "<code><nowiki>|content=</nowiki></code>" and then added content after "<code><nowiki>|content=</nowiki></code>".</span> <div lang="en" dir="ltr" class="mw-content-ltr"> You can also look for a notice at the bottom of the page similar to this: "The above documentation is transcluded from Template:''Templatename''/doc". </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==== Templates without documentation subpages ==== </div> <span lang="en" dir="ltr" class="mw-content-ltr">If a template doesn't have a documentation subpage, create it and move the template's documentation there (or a placeholder for it).</span> <span lang="en" dir="ltr" class="mw-content-ltr">Then you can add template data to the documentation subpage.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> ===== Creating the subpage and moving the documentation ===== </div> {{Note|1=<span lang="en" dir="ltr" class="mw-content-ltr">On many Wikimedia wikis, you can only create a page if you have been a registered user there for a number of days and have made a minimum number of edits.</span>|2=info}} <div lang="en" dir="ltr" class="mw-content-ltr"> To create the documentation subpage, click <code>{{int|vector-view-edit}}</code>/<code>{{int|visualeditor-ca-editsource}}</code> on the main template page; look for the {{tag|noinclude|open}} tags and their contents (usually at the bottom). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> It should look something like this: </div> <syntaxhighlight lang="wikitext"> <noinclude> {{Documentation|content= == Usage == Information about usage. == More example headings == More example contents [[Category:Example category]] [[Category:Example category 2]] }} </noinclude></syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">You may also find that it already contains template data.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If so, it will look something like this:</span> <syntaxhighlight lang="wikitext"> <noinclude> {{Documentation|content= ... <templatedata> { "description": "", "params": { "1": { "label": "Example parameter", "description": "Example parameter description", "type": "string" } } } </templatedata> </noinclude></syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">Select everything after "<code><nowiki>|content=</nowiki></code>" and before "{{tag|noinclude|close}}" and cut it into your clipboard or save it in a temporary document.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Delete "<code><nowiki>|content=</nowiki></code>", leaving only the following:</span> <syntaxhighlight lang="wikitext"> <noinclude> {{Documentation}} </noinclude></syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> Save the template page. </div> <span lang="en" dir="ltr" class="mw-content-ltr">Now, to create the new subpage, look at your browser's address bar and add /doc to the end of the URL.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Press {{Key press|Enter}}, then choose the option to create a new page.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If this wiki has a {{((}}{{ll|Template:Documentation_subpage|Documentation subpage}}{{))}} notice template, add it at the top of the new page.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You may also wish to add other templates, such as a {{((}}{{ll|Template:Purge_button|Purge button}}{{))}} or {{((}}{{ll|Template:Purge|Purge}}{{))}} link (if supported by the wiki in question).</span> <div lang="en" dir="ltr" class="mw-content-ltr"> Insert the text you cut or saved in the previous text (beneath the notice template, if applicable). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Wrap any categories in {{tag|includeonly|open}} tags so that they apply only to the template's main page: </div> <syntaxhighlight lang="wikitext"> <includeonly> [[Category:Example category]] [[Category:Example category 2]] </includeonly> </syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">Many wikis have a <code><nowiki>{{Sandbox other}}</nowiki></code> template.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Use this template here if it's likely that the template you're editing exists in a sandbox version (located at "Template:''Templatename''/sandbox") in order to prevent the categories from applying to the sandbox page:</span> <syntaxhighlight lang="wikitext"> <includeonly>{{sandbox other|| [[Category:Example category]] [[Category:Example category 2]] }}</includeonly> </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> Finally, publish the page. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> You can now add and edit the template data on the documentation subpage using the instructions described in [[#Methods|#Methods]]. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===== Adding and editing template data on the main template page ===== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If you can't create the /doc page, you can add and edit template data on the template's main page by following the instructions in [[#Methods|#Methods]]. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If a template has a documentation subpage, check both the main page and the documentation subpage for the presence of template data (the {{tag|templatedata|open}} tag followed by an array inside curly brackets: <code>{}</code>). </div> <span lang="en" dir="ltr" class="mw-content-ltr">Alternatively, the TemplateData extension can perform this check for you.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Click <code>{{int|vector-view-edit}}</code> or <code>{{int|visualeditor-ca-editsource}}</code> on either page.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If the template already has template data on either page, you will see a yellow notice at the top of the page saying either:</span> : ''{{int|templatedata-exists-on-related-page|2=<span lang="en" dir="ltr" class="mw-content-ltr">Template:Templatename/doc</span>}}'' <span lang="en" dir="ltr" class="mw-content-ltr">or</span> : ''{{int|templatedata-exists-on-related-page|2=<span lang="en" dir="ltr" class="mw-content-ltr">Template:Templatename</span>}}'' <div lang="en" dir="ltr" class="mw-content-ltr"> '''If the template has template data on its documentation subpage''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">If the template has template data on its documentation subpage, this is the page you should edit.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can do this by clicking the "[edit]" located after the heading "[[File:Test Template Info-Icon - Version (2).svg|50px]] '''Template documentation'''" (or similar), or, if you are already on the /doc page, by clicking <code>{{int|vector-view-edit}}</code> or <code>{{int|visualeditor-ca-editsource}}</code> at the top.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Follow the guidance at [[#Methods|#Methods]] to add or edit the template data.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''If the template has template data on its main page''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If the template has template data on its main page, you once again have two options: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * You can either move to its documentation subpage. This is the preferred option. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * Or, you can edit it on the main template page. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Moving template data to the documentation subpage''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">To do this, click <code>{{int|vector-view-edit}}</code>/<code>{{int|visualeditor-ca-editsource}}</code> on the main template page, and look for the {{tag|templatedata|open}} tags, enclosed within {{tag|noinclude|open}} tags.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It should look something like this:</span> <syntaxhighlight lang="xml"> <noinclude> {{Documentation}} <templatedata> { "description": "", "params": { "1": { "label": "Example parameter", "description": "Example parameter description", "type": "string" } } } </templatedata> </noinclude> </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> Cut only the {{tag|templatedata|open}} tags and their contents out of the code, then save the page. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Next, edit the documentation subpage by clicking the "[edit]" located after the heading "[[File:Test Template Info-Icon - Version (2).svg|50px]] '''Template documentation'''" (or similar). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Type a heading, like "Template data", then beneath it paste the template data. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> You can now edit the template data based on the guidance at [[#Methods|#Methods]]. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Editing template data on the main template page''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">If you do not wish to move the template data to the /doc page, you can edit it on the main template page.</span> <span lang="en" dir="ltr" class="mw-content-ltr">See [[#Methods|#Methods]] for how to edit template data.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''If the template does not yet have template data but has a doc subpage''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If the template does not yet have template data, you should add it to the documentation subpage. </div> <span lang="en" dir="ltr" class="mw-content-ltr">Do this by clicking the "[edit]" located after the heading "[[File:Test Template Info-Icon - Version (2).svg|50px]] '''Template documentation'''" (or similar), or, if you are already on the /doc page, by clicking <code>{{int|vector-view-edit}}</code> or <code>{{int|visualeditor-ca-editsource}}</code> at the top.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Type a heading, like "Template data", then add it beneath this heading.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The section [[#Methods|#Methods]] explains how to add template data.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> === Methods === </div> {{anchor|TemplateData editor}} <div lang="en" dir="ltr" class="mw-content-ltr"> ==== Template data editor method ==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> This is a simple way to add or edit template data, recommended for less experienced users. </div> <span lang="en" dir="ltr" class="mw-content-ltr">The template data editor is a graphical user interface for adding and editing template data.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It is part of the TemplateData extension, available on any template's page (or documentation subpage) by clicking <code>{{int|vector-view-edit}}</code> or <code>{{int|visualeditor-ca-editsource}}</code>.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> After clicking <code>{{int|vector-view-edit}}</code> or <code>{{int|visualeditor-ca-editsource}}</code>, you will see a button above the editing area and page title that says <code>{{int|templatedata-editbutton}}</code>. </div> {{Clear}} [[{{lm|Manage template documentation button for TemplateData 2014|png|_}}|453px]] <span lang="en" dir="ltr" class="mw-content-ltr">Clicking this button will take you to the '''template data editor'''.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If the page you are on already contains template data, it will automatically appear here.</span> {{Clear}} [[{{lm|TemplateData GUI editor new|png|_}}|alt=<span lang="en" dir="ltr" class="mw-content-ltr">A screenshot of the template data editing tool</span>|600px|<span lang="en" dir="ltr" class="mw-content-ltr">The template data editing tool, on a page with no template data.</span>]] <div lang="en" dir="ltr" class="mw-content-ltr"> Features in the above window: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * The top item chooses the language of the interface text. It allows you to enter text content in multiple languages, displayed to users based on their settings in Preferences, '''not based on the wiki's language'''; different wikis have entirely different template databases. </div> <span lang="en" dir="ltr" class="mw-content-ltr">If no language template data exists, the interface will only offer users the wiki's own language, but users can click <code>{{int|templatedata-modal-button-add-language}}</code> to add more inputs.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The language code is displayed in brackets next to the parameters to which it can be applied, such as descriptions and labels.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> * The next item is the template description. This is the description of the template as a whole; it's shown to users in numerous places in the template editors while adding a template. This [[#Description|parameter and its effects are documented below]]. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * The third item controls the wikitext formatting of the template. </div> <span lang="en" dir="ltr" class="mw-content-ltr">This parameter determines how the wikitext will be laid out when the user clicks <code>{{int|templatedata-modal-button-apply}}</code>, the two main types being <code>"inline"</code> (on one line) and <code>"block"</code> (on new lines).</span> <span lang="en" dir="ltr" class="mw-content-ltr">This [[#Format|parameter and its effects are documented below]].</span> <div lang="en" dir="ltr" class="mw-content-ltr"> :If the user chooses <code>{{int|templatedata-modal-format-custom}}</code>, they can enter wikitext under <code>{{int|templatedata-modal-title-templateformatstring}}</code> according to [[#Custom formats|Custom formats rules documented below]], in order to create a custom layout for the template when the user clicks <code>{{int|templatedata-modal-button-apply}}</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * The fourth item configures a template's parameters. </div> <span lang="en" dir="ltr" class="mw-content-ltr">If parameters have already been defined in template data, this area displays them in a list.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If the template's source code specifies parameters for which no template data exists, you may see a button labeled <code>{{int|templatedata-modal-table-param-importoption|2}}</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The editor extracts these suggestions from the template's source code by looking for <code><nowiki>{{{parametername}}}</nowiki></code> or <code><nowiki>{{{parametername|}}}</nowiki></code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Clicking <code>{{int|templatedata-modal-table-param-importoption|2}}</code> will add these parameters using their names as defined in the source code.</span> <span lang="en" dir="ltr" class="mw-content-ltr">A green notice will also appear at the top, for example, "{{int|Templatedata-modal-notice-import-numparams|2|''names of parameters''}}".</span> <div lang="en" dir="ltr" class="mw-content-ltr"> * At the bottom of the window you see an <code>{{int|templatedata-modal-button-addparam}}</code> button. This allows you to add a parameter manually with a custom name. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Continue to the next step by clicking any one of the parameters in the list. This will allow you to edit that parameter's info. </div> [[{{lm|TemplateData_GUI_editor_parameter_list|png|_}}|alt=<span lang="en" dir="ltr" class="mw-content-ltr">Screenshot of the template data editor, showing parameter options</span>|600px]] <div lang="en" dir="ltr" class="mw-content-ltr"> All of these features and their effects are outlined in the section [[#Within the parameter's name|#Within a parameter's name]]. </div> {{note|1= <div lang="en" dir="ltr" class="mw-content-ltr"> * The template data editor will not allow you to change a parameter to a blank "[[#Parameter name|{{int|Templatedata-modal-table-param-name}}]]". </div> <span lang="en" dir="ltr" class="mw-content-ltr">Parameters in template data that somehow acquire blank strings as names will not cause issues in the 2010 wikitext editor with TemplateWizard, but neither the visual editor nor the 2017 wikitext editor will display them at all.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This is the only mandatory field in the template data editor.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> * Clicking <code>{{int|templatedata-modal-button-delparam}}</code> will delete the parameter and all its information from the template data. </div> <span lang="en" dir="ltr" class="mw-content-ltr">You can't retrieve or undo this in the template data unless you click "X" afterwards.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can undo any changes made after clicking <code>{{int|templatedata-modal-button-apply}}</code> by hitting {{Key press|Ctrl|Z}}.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> * Exiting the template data editor after making changes prompts you to confirm that you want to discard your changes. </div> }} <span lang="en" dir="ltr" class="mw-content-ltr">When finished, click <code>{{int|templatedata-modal-button-apply}}</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This will automatically insert the template data at the bottom of the page before the {{tag|noinclude|close}} tag; or, if already present, it will be updated with the new information without changing its position.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The template data text will also be selected when you click <code>{{int|templatedata-modal-button-apply}}</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The template data editor creates a <code>"paramOrder"</code> parameter at the bottom of the template data (or updates it if it already exists).</span> <span lang="en" dir="ltr" class="mw-content-ltr"><code>paramOrder</code> contains the current template data parameters in the order in which they were displayed by the template data editor.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can change the <code>paramOrder</code> by dragging the parameters up and down in the template data editor using the three horizontal bars on the left.</span> <span lang="en" dir="ltr" class="mw-content-ltr"><code>[[#ParamOrder|paramOrder]]</code> and its effects are documented below.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> After this, click <code>{{int|templatedata-modal-button-saveparam}}</code> to save your revision of the page. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==== Manual method ==== </div> <span lang="en" dir="ltr" class="mw-content-ltr">You can also add or edit template data manually.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Template data is written in [[w:JSON|JSON]], but you do not need to learn JSON to learn how to create template data.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Template data follows a few very simple rules and accepts only a few dozen possible predefined parameters and values, typically following a <code><nowiki>"parameter": "value"</nowiki></code> format.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Adding template data manually''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Considerations: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * If you're adding template data on a template's documentation subpage ('''recommended'''), you may add it anywhere on the page; check to see if your language's Wikipedia has a preferred location for it. For example, on the English Wikipedia, template data is typically near the bottom of the documentation page; on the German Wikipedia, it is typically at the top. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * If you're adding template data on a template's main page ('''not recommended'''; see [[#Prior checks|#Prior checks]]), you must make sure to place it inside the {{tag|noinclude}} tags. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Click <code>{{int|vector-view-edit}}</code> or <code>{{int|visualeditor-ca-editsource}}</code> on the respective page, then move to the place in the page where you intend to add template data and write a heading: "Template data". </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Many wikis have a {{tl|TemplateData header}} template that adds a short notice regarding template data. If your wiki does, add it after the heading. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> To start adding template data, type an opening and closing {{tag|templatedata|open}} tag and a pair of curly brackets on new lines, with an empty line between them: </div> <syntaxhighlight lang="html"> <templatedata> { } </templatedata></syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> Next, add an indent on the empty line between the two curly brackets, and start adding parameters. Details for the parameters can be found at [[#Template data parameters|#Template data parameters]]. Most are optional; some are highly recommended. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Parameters can be in any order, but what follows is the order that best conforms to template data documentation and makes the content easiest to use for editors: </div> <syntaxhighlight lang="html"> <templatedata> { "description": "", "format": "", "params": { "parameter1": { "aliases": ["",""] "label": "", "description": "", "type": "" } }, "paramOrder": [ "" ] } </templatedata></syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> Make sure the parameters, for example, in the <code>"params"</code> object, remain inside that object; otherwise you will trigger an "[[#Unexpected property|{{int|templatedata-invalid-unknown|<var>propertyname</var>}}]]" error when you try to save. </div> {{anchor|Example}} '''<span lang="en" dir="ltr" class="mw-content-ltr">Example</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">Here is some example template data for a hypothetical cleanup template.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Such a template would display a notice and place the page into a dated category based on the month and year entered.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The notice might also contain a link to a talk page section. The template data would look something like this:</span> <syntaxhighlight lang="javascript"> <templatedata> { "description": "Use this template to indicate that an article is in need of cleanup.", "format": "inline", "params": { "date": { "label": "Month and year", "description": "The month and year that the template was added", "type": "string", "autovalue": "{{SUBST:CURRENTMONTHNAME}} {{SUBST:CURRENTYEAR}}", "example": "January 2013", "suggested": true }, "reason": { "aliases": ["1"], "label": "Reason", "description": "The reason the article is in need of cleanup", "type": "string" }, "talk": { "aliases": ["talksection"], "label": "Talk page section", "description": "The section of the talk page containing relevant discussion", "type": "string" } }, "paramOrder": [ "date", "reason", "talk" ] } </templatedata> </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> The corresponding template data documentation would display as follows: </div> <templatedata> { "description": "Use this template to indicate that an article is in need of cleanup.", "format": "inline", "params": { "date": { "label": "Month and year", "description": "The month and year that the template was added", "type": "string", "autovalue": "{{SUBST:CURRENTMONTHNAME}} {{SUBST:CURRENTYEAR}}", "example": "January 2013", "suggested": true }, "reason": { "aliases": ["1"], "label": "Reason", "description": "The reason the article is in need of cleanup", "type": "string" }, "talk": { "aliases": ["talksection"], "label": "Talk page section", "description": "The section of the talk page containing relevant discussion", "type": "string" } }, "paramOrder": [ "date", "reason", "talk" ] } </templatedata> {{anchor|Description and parameters}} <div lang="en" dir="ltr" class="mw-content-ltr"> == Template data parameters == </div> <span lang="en" dir="ltr" class="mw-content-ltr">All available template data parameters (i.e those between tags <code><nowiki><templatedata>...</templatedata></nowiki></code> of the wiki source) are listed below with a description and example.</span> <span lang="en" dir="ltr" class="mw-content-ltr">They are also listed in more technical detail at [[Special:MyLanguage/Extension:TemplateData#Format|Extension:TemplateData#Format]].</span> {{note|1=<nowiki/> * <span lang="en" dir="ltr" class="mw-content-ltr">This information is current as of November 2021 and may change if new parameters are added or the template editing interfaces get updates to support existing parameters or treat certain parameters differently.</span> * <span lang="en" dir="ltr" class="mw-content-ltr">Wiki markup will not work in descriptions or labels.</span> <span lang="en" dir="ltr" class="mw-content-ltr">They are strictly plain text strings.</span> * <span lang="en" dir="ltr" class="mw-content-ltr">New lines ("<code>\n</code>") in descriptions, labels, examples or defaults will not show in any of the main editors (TemplateWizard, the visual editor or the 2017 wikitext editor), even though they show in the auto-generated template data documentation.</span> <span lang="en" dir="ltr" class="mw-content-ltr">They are replaced by a null string in input forms and by a space elsewhere.</span> }} {| class="wikitable" !style="width:5%"| <span lang="en" dir="ltr" class="mw-content-ltr">Parameter</span> !style="width:75%"| <span lang="en" dir="ltr" class="mw-content-ltr">Description</span> !style="width:20%"| <span lang="en" dir="ltr" class="mw-content-ltr">Example</span> |- style="visibility:collapse" | colspan="3" | {{anchor|description|Description|Template description}} |- ! <code>description</code> | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"description"</code> parameter describes what the template does.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It is optional but highly recommended.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> On the template documentation page, the description will show in plain text below the "Template data for [template name]" subheading. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> In all main editors ({{ll|VisualEditor}}, the {{ll|2017 wikitext editor}} and the {{ll|Extension:WikiEditor|nsp=0}} with [[Special:MyLanguage/Help:Extension:TemplateWizard|TemplateWizard]]), the description shows in two main instances: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * below the template name in each search suggestion when the user is searching for a template </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * below the template name in the template editor, while they are adding values to parameters in the template. </div> <span lang="en" dir="ltr" class="mw-content-ltr">In the visual editor and 2017 wikitext editor, the description gets truncated to about 50 characters under each search suggestion, followed by a "...", but the whole description shows in the main template editor window.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Both are shown in grey text.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In the main template editor window, descriptions longer than four lines (about 540 characters) are provided a separate scrollbar, and they are shown in black text.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">If not specified</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">If the description parameter does not exist or is not specified, the text <code>{{int|templatedata-doc-desc-empty}}</code> will be displayed in the template data documentation below the "Template data for [template name]" subheading.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Additionally:</span> * <span lang="en" dir="ltr" class="mw-content-ltr">in the visual editor and the 2017 wikitext editor, it will behave the same as a template that does not have template data; instead of a description, the following text will display:</span> ::<code>{{int|quotation-marks|2=<span lang="en" dir="ltr" class="mw-content-ltr">The "Template:''Templatename''" template doesn't yet have a description, but there might be some information on the template's page.</span>}}</code> * <span lang="en" dir="ltr" class="mw-content-ltr">in the 2010 wikitext editor with TemplateWizard, the following text will display where the description would be (except in search suggestions):</span> :<code>{{int|quotation-marks|{{int|templatewizard-no-description}}}}</code> :<span lang="en" dir="ltr" class="mw-content-ltr">This is different from the two standard placeholder descriptions in cases when template data doesn't exist:</span> :*<code>{{int|quotation-marks|2=<span lang="en" dir="ltr" class="mw-content-ltr">Due to missing template data, parameters for this template have been auto-generated.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Please be aware that they may not be accurate.</span>}}</code> :*<code>{{int|quotation-marks|2=<span lang="en" dir="ltr" class="mw-content-ltr">No parameters could be determined for this template due to absence of template data documentation.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You may insert the template without parameters.</span>}}</code> | <syntaxhighlight lang="javascript"> "description": "A template for linking to a commons category", </syntaxhighlight> |- style="visibility:collapse" |colspan="3"| {{anchor|format|Format}} |- ! <code>format</code> | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"format"</code> parameter describes how the template's wikitext should be laid out.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This can be set to the standard formats of <code>"inline"</code> and <code>"block"</code>, or the user can input a set of wikitext symbols to create a custom format; these symbols and some examples are listed in the section [[#Custom formats|#Custom formats]].</span> <span lang="en" dir="ltr" class="mw-content-ltr">This parameter is not required, but it is recommended.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The default behavior when this parameter is not provided is preserving the existing formatting for existing parameters, or inline formatting for newly added parameters and templates.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' '''<span lang="en" dir="ltr" class="mw-content-ltr">Inline:</span>''' (<code>"inline"</code>) <div lang="en" dir="ltr" class="mw-content-ltr"> When inserted, the template will lay its wikitext out on a single line with no white space between elements, like so: </div> :<code><nowiki>{{Foo|bar=baz|longparameter=quux}}</nowiki></code> '''<span lang="en" dir="ltr" class="mw-content-ltr">Block:</span>''' (<code>"block"</code>) <div lang="en" dir="ltr" class="mw-content-ltr"> When inserted, the template will distribute its parameters each on a new line, with single spaces between each element, like so: </div> <pre>{{Foo | bar = baz | longparameter = quux }}</pre> '''<span lang="en" dir="ltr" class="mw-content-ltr">Custom formatting:</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> Alternatively, if the parameter is set to a custom string of wikitext, as per the rules listed at [[#Custom formats|#Custom formats]], the template will lay its wikitext out as per the given wikitext. </div> | <syntaxhighlight lang="javascript"> "format": "inline" </syntaxhighlight> |- style="visibility:collapse" |colspan="3"| {{anchor|params|Params|Multiple parameters}} |- ! <code>params</code> | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"params"</code> object contains the information for each parameter of the template. It is required, and its parameters can be viewed in the [[#Within params|#Within params]] section.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> It should contain the [[#Parameter name|name]] of each parameter followed by a set of template data sub-parameters listed in [[#Within the parameter's name|#Within a parameter's name]]. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If there are multiple parameters, place a comma ''between'' each parameter object, but do not add one after the last curly bracket (see example). </div> | <syntaxhighlight lang="javascript"> "params": { "parameter1": { ... // parameter info }, // comma here "parameter2": { ... // parameter info }, // and here "parameter3": { ... // parameter info } // but not here } </syntaxhighlight> |- style="visibility:collapse" |colspan="3"| {{anchor|paramOrder|ParamOrder|Paramorder}} |- ! <code>paramOrder</code> | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"paramOrder"</code> object is an optional object that causes the parameters of a template to be displayed in a specific order when added in the template editor.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''How to use''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">Add the parameter <code>"paramOrder"</code>, followed by a colon, a space and an open square bracket, then type the name of each of the template's parameters in double quotation marks (<code>"</code>) in the desired order, separated by commas.</span> <span lang="en" dir="ltr" class="mw-content-ltr">End with a closed square bracket (creating an array).</span> <div lang="en" dir="ltr" class="mw-content-ltr"> The parameters need not be on new lines (they may be written as <code>"paramOrder": ["param1","param2","param3"]</code>), but placing them on new lines often helps readability. </div> <span lang="en" dir="ltr" class="mw-content-ltr">We recommend you place <code>"paramOrder"</code> after <code>"params"</code>, as the template data editor does; it isn't displayed in the template data documentation but simply forces the order of the parameters.</span> <span lang="en" dir="ltr" class="mw-content-ltr">A future editor may wish to quickly look through the parameter details and edit them rather than scrolling past the <code>"paramOrder"</code>, especially if there are a lot of parameters.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If you do choose to place paramOrder somewhere besides the end of the template data, end it with a comma.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> You must include every parameter mentioned in the template data; otherwise a "[[#Required property|{{int|templatedata-invalid-missing|''propertyname''}}]]" error will show. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''If not specified''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Without <code>"paramOrder"</code>, the template's parameters will display in the order in which the template's source code declares them. If the source code contains objects inside objects, the parameters in outer objects will come first, followed by inner objects. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> In the 2010 wikitext editor with TemplateWizard: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * <code>"[[#Required|required]]"</code> parameters always appear at the top, regardless of the order in <code>"paramOrder"</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * <code>"[[#Suggested|suggested]]"</code> parameters will always appear second, above <code>"optional"</code> ones. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * <code>"[[#Deprecated|deprecated]]"</code> parameters won't appear at all in this editor; see the description of <code>"deprecated"</code> for more info. </div> * <span lang="en" dir="ltr" class="mw-content-ltr"><code>"paramOrder"</code> will only enforce its order within these categories (i.e., all <code>"required"</code> parameters will be in the order specified by <code>"paramOrder"</code>, and all <code>"suggested"</code> parameters will be too, but all <code>"suggested"</code> parameters will appear below all <code>"required"</code> parameters).</span> <div lang="en" dir="ltr" class="mw-content-ltr"> In the visual editor and the 2017 wikitext editor, <code>"paramOrder"</code> forces its order regardless of the status of each parameter. </div> | <syntaxhighlight lang="javascript"> "paramOrder": [ "date", "reason", "talk" ] </syntaxhighlight> |} <div lang="en" dir="ltr" class="mw-content-ltr"> === Within params === </div> {| class="wikitable" !style="width:5%"| <span lang="en" dir="ltr" class="mw-content-ltr">Parameter</span> !style="width:75%"| <span lang="en" dir="ltr" class="mw-content-ltr">Description</span> !style="width:20%"| <span lang="en" dir="ltr" class="mw-content-ltr">Example</span> |- style="visibility:collapse" | colspan="3" | {{anchor|Parameter name}} |- ! ''{{int|templatedata-modal-placeholder-paramkey}}'' | <span lang="en" dir="ltr" class="mw-content-ltr">The only first-level item of the <code>params</code> object is the name of a parameter of the template.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> For example, in a template's source code, <code><nowiki>{{{date}}}</nowiki></code> denotes a parameter, and it should be added under <code>"params"</code> with the name <code>"date"</code>. </div> <span lang="en" dir="ltr" class="mw-content-ltr">You may also see parameters named <code><nowiki>{{{1}}}</nowiki></code> or another number (whose template data name should be, for example, <code>"1"</code>).</span> <span lang="en" dir="ltr" class="mw-content-ltr">Parameters like this prevent a user inserting a template from having to type the parameter name and the equals sign (i.e., <code><nowiki>|value|</nowiki></code> instead of <code><nowiki>|parametername=value|</nowiki></code>).</span> <span lang="en" dir="ltr" class="mw-content-ltr">When there are multiple unnamed parameters, the number identifies which [[Special:MyLanguage/Help:Templates#Anonymous parameters|unnamed parameter]] is being referred to.</span> <span lang="en" dir="ltr" class="mw-content-ltr">For example, in:</span> :<code><nowiki>{{example template|value1|value2}}</nowiki></code> <span lang="en" dir="ltr" class="mw-content-ltr"><code><nowiki>value1</nowiki></code> is the value of parameter <code><nowiki>{{{1}}}</nowiki></code>, and <code><nowiki>value2</nowiki></code> is the value of parameter <code><nowiki>{{{2}}}</nowiki></code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Describe your template data parameters accordingly.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Note: a user can still force the use of <code><nowiki>{{{2}}}</nowiki></code> without <code><nowiki>{{{1}}}</nowiki></code> by inserting a parameter named "<code>2</code>" in the template editor or typing "<code><nowiki>|2=</nowiki></code>" in wikitext.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Finally, note that <code>"aliases"</code> creates alternatives to the parameter name which can be used interchangeably, and <code>"label"</code> replaces the parameter name '''in the user interface''' with the specified label (for situations in which the parameter name is not human readable or easily understood).</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''How to use''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">Each of these <code>{{int|templatedata-modal-placeholder-paramkey}}</code> objects should contain all of the information about the parameter, in the form of more template data parameters.</span> <span lang="en" dir="ltr" class="mw-content-ltr">These are listed in the following section, [[#Within the parameter's name|Within a parameter's name]].</span> | <syntaxhighlight lang="javascript"> "1": { // name of the parameter ... // information about the parameter goes here } </syntaxhighlight> |} {{anchor|Within the parameter's name|Within a parameter's name}} <div lang="en" dir="ltr" class="mw-content-ltr"> ==== Within the parameter's name ==== </div> {| class="wikitable" ! style="width: 5%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Parameter</span> ! style="width: 70%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Description</span> ! style="width: 25%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Example</span> |- style="visibility:collapse" | colspan="3" | {{anchor|aliases|Aliases|Parameter aliases}} |- ! aliases | <span lang="en" dir="ltr" class="mw-content-ltr">The optional <code>"aliases"</code> parameter allows a template parameter to have multiple names.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can check this by going into the template's source code and looking for:</span> :<code><nowiki>{{{parameter1|{{{parameter2}}}}}}</nowiki></code> <div lang="en" dir="ltr" class="mw-content-ltr"> or </div> :<code><nowiki>{{{parameter1|{{{parameter2|}}}}}}</nowiki></code> <span lang="en" dir="ltr" class="mw-content-ltr">This means that if the user inserts either of these parameters with a value, they will perform the same function.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Literally, it translates to, "Value of parameter1. If parameter1 doesn't exist or have a value: value of parameter2."</span> <span lang="en" dir="ltr" class="mw-content-ltr">In the second case, it also means, "If parameter2 doesn't exist or have a value: no value."</span> <span lang="en" dir="ltr" class="mw-content-ltr">To insert the <code>"aliases"</code> parameter, add the text <code>"aliases"</code> followed by a colon, a space and an open square bracket, then typing the name of each of the parameter's aliases in quotation marks, separated by commas.</span> <span lang="en" dir="ltr" class="mw-content-ltr">End with a closed square bracket, creating an array.</span> | <syntaxhighlight lang="javascript"> "aliases": ["1", "talk", "talksection"], </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|inherits|Inherits|Similar parameters}} |- ! inherits | <span lang="en" dir="ltr" class="mw-content-ltr"><code>"inherits"</code> is an optional parameter for when a parameter should inherit all of the template data of another parameter.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This can then be overridden by any parameters specified for the inheriting parameter.</span> <span lang="en" dir="ltr" class="mw-content-ltr">To use this parameter, type <code>"inherits" :</code> followed by another template parameter's name, such as <code>"talk"</code> or <code>"1"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can then type another specific setting for the parameter underneath if you wish, like <code>"label" : "A different label"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The first parameter will inherit all of the second parameter's properties except this one.</span> | <syntaxhighlight lang="javascript"> "params": { "topic1": { "label": "Topic", "description": "A topic mentioned on this disambiguation page", "type": "string" }, "topic2": { "inherits": "topic1" }, "topic3": { "inherits": "topic1", "label" : "A different label" } } </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|label|Label}} |- ! label | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"label"</code> parameter is a human-readable title for the parameter that will be displayed within the template editor.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The label is displayed in place of the parameter's raw name at all times, including when an alias is used in the wikitext.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This parameter is optional but highly recommended.</span> | <syntaxhighlight lang="javascript"> "label": "Month and year", </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|Parameter description}} |- ! description | <span lang="en" dir="ltr" class="mw-content-ltr">Here, <code>"description"</code> is a description of the parameter, not the template as a whole.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This description appears below the parameter name (a long descriptions will be shortened with a button to optionally expand it).</span> <span lang="en" dir="ltr" class="mw-content-ltr">It is optional but highly recommended.</span> | <syntaxhighlight lang="javascript"> "description": "The month and year that the template was inserted", </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|type|Type}} |- ! type | <span lang="en" dir="ltr" class="mw-content-ltr">See the [[#Type parameter|#Type parameter]] section.</span> | |- style="visibility:collapse" | colspan="3" | {{anchor|default|Default}} |- ! default | <span lang="en" dir="ltr" class="mw-content-ltr">Some template parameters have a default value which is used unless overridden by the user.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"default"</code> item is an optional item, documentary only, that is intended to communicate this default value to the user.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The value need not match the actual default (if there is one) and has '''no functional effect'''.</span> <span lang="en" dir="ltr" class="mw-content-ltr">(Not to be confused with <code>"autovalue"</code>, which '''is''' a functional parameter that fills in a field for the user.)</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), the <code>"default"</code> text will show as grey text in the input box of any open parameter when it is empty, in the format <code>"Default: ''default text''"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Additionally, it will show in plain black text in the [[#Parameter description|parameter description]] (when the user hovers over the "i" symbol).</span> <span lang="en" dir="ltr" class="mw-content-ltr">In the visual editor and the 2017 wikitext editor, this will be below the parameter description, below "Field is [[#Required|required]]"/"Field is [[#Deprecated|deprecated]]", if specified (the 2010 wikitext editor doesn't show this text), and above "[[#Example|example]]", if specified (<code>"example"</code> does not show in the parameter description in the 2010 wikitext editor).</span> <span lang="en" dir="ltr" class="mw-content-ltr">In the 2010 wikitext editor with TemplateWizard, the <code>"default"</code> text shows directly after the parameter description, on the same line, following a space.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It shows in the same format as the other editors (<code>"Default: ''default text''"</code>).</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), if <code>"default"</code> is specified, the <code>"example"</code> value will not show in the input box. </div> | <syntaxhighlight lang="javascript"> "default": "Category:CommonsRoot", </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|autovalue|Autovalue|Auto value}} |- ! autovalue | <span lang="en" dir="ltr" class="mw-content-ltr">A parameter can be assigned an <code>"autovalue"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">When a user adds the template to a page, this value will automatically appear in the input box.</span> <span lang="en" dir="ltr" class="mw-content-ltr">For example, many cleanup templates need the date added; setting the <code>"autovalue"</code> for the template's <code>date</code> parameter to be <code><nowiki>{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}</nowiki></code>, the month and year that the template was added will be filled in automatically.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This value can be overwritten by the user in the template editor.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"autovalue"</code> overrides the visible effects of <code>"url"</code> in the visual editor and the 2017 wikitext editor.</span> <span lang="en" dir="ltr" class="mw-content-ltr">See [[#Type|the description for <code>"type"</code>]] for more info.</span> | <syntaxhighlight lang="javascript"> "autovalue": "{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}" </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|example|Example}} |- ! example | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"example"</code> parameter is optional and documentary only; its value contains an example that helps the template's user understand the correct way to fill in the parameter (not to be confused with <code>"suggested"</code>; see that entry for more information).</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), this property is displayed below the parameter description (and below the <code>"default"</code> text, if specified).</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"example"</code> will not show in the input box if "default" is specified. </div> | <syntaxhighlight lang="javascript"> "example": "January 2013", </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|suggestedvalues}} |- ! suggested values | <span lang="en" dir="ltr" class="mw-content-ltr">The parameter property <code>suggestedvalues</code> lets you define a list of parameter values to be shown to visual editor users in a dropdown for easy selection. This can be done either directly in JSON or using the template data editor (no coding required).</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can add suggested values to be displayed in the visual editor for parameters which have their type set to one of the following options ([[Special:MyLanguage/Extension:TemplateData#Param object|reference]]):</span> * {{int|templatedata-doc-param-type-content}} * {{int|templatedata-doc-param-type-line}} * {{int|templatedata-doc-param-type-string}} * {{int|templatedata-doc-param-type-number}} * {{int|templatedata-doc-param-type-unknown}} * {{int|templatedata-doc-param-type-unbalanced-wikitext}} <div lang="en" dir="ltr" class="mw-content-ltr"> Other types (file, page, template, user, date, boolean, URL) are not currently supported because they have special functionalities in the visual editor already, such as autocomplete, which would interfere with the drop-down menu for suggested values in the visual editor. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">Editing template data as JSON in wikitext</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> To add suggested values to any parameter type, add the new property "suggestedvalues" to the parameter in JSON. The “suggestedvalues” attribute must be a list of strings. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">Editing template data with the template data editor</span>''' # <span lang="en" dir="ltr" class="mw-content-ltr">Click on <code>{{int|templatedata-editbutton}}</code>.</span> # <span lang="en" dir="ltr" class="mw-content-ltr">Click on the name of the parameter you want to add suggested values to.</span> # <span lang="en" dir="ltr" class="mw-content-ltr">If it’s not already done, set parameter type to one of the following: content, line, string, number, unknown, unbalanced wikitext.</span> <span lang="en" dir="ltr" class="mw-content-ltr">A new input field <code>{{int|templatedata-modal-table-param-suggestedvalues}}</code> will appear.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If the parameter is already set to one of these types, the input field should already be visible.</span> # <span lang="en" dir="ltr" class="mw-content-ltr">Type in the suggested value(s), including any spaces and special characters, and press enter to add the value(s) to the list.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">Once the values have been added to template data, the visual editor will display them in a combo box (a dropdown into which users can also enter a custom value) for the parameter types listed above. The user selects the desired value by clicking on it. If the list of values is long -- for example, a list of a country’s states -- the user can begin typing in the field, whereupon the list will be filtered to show only values containing the typed text. To change an entered value, the user must simply clear the field, and the full dropdown list will appear again. If the user needs a value not included in the list (for example, "message in a bottle") they can type it in manually.</span> |<syntaxhighlight lang="javascript"> "suggestedvalues": [ "Journal", "Book", "Newspaper", "Magazine" ] </syntaxhighlight> |- |} {| class="wikitable" ! style="width: 5%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Status option</span> ! style="width: 70%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Description</span> ! style="width: 25%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Example</span> |- style="visibility:collapse" | colspan="3" | {{anchor|required|Required}} |- ! required | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"required"</code> parameter can be set to either <code>true</code> or <code>false</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">When unspecified the value defaults to <code>false</code>.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> It determines whether filling in the given parameter is mandatory for the template. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> This status has several effects in the visual editor and the {{ll|2017 wikitext editor}}: </div> *<span lang="en" dir="ltr" class="mw-content-ltr">it displays the parameter automatically when a user inserts the template;</span> *<span lang="en" dir="ltr" class="mw-content-ltr">it shows a black asterisk within the input box, on the right;</span> *<span lang="en" dir="ltr" class="mw-content-ltr">it shows the grey, italic text <code>{{int|Visualeditor-dialog-transclusion-required-parameter-description}}</code> below the parameter description;</span> *<span lang="en" dir="ltr" class="mw-content-ltr">it makes the input box glow red if the user clicks away without entering a value;</span> *<span lang="en" dir="ltr" class="mw-content-ltr">if a user attempts to insert the template without a value in the required parameter, it will show them a prompt, asking if they are sure.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If they confirm, it will insert the parameter with a blank value.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It will not stop them from inserting the template, though, and it does not result in a visible error by itself (though templates can be programmed to display an error when a required parameter is not filled in).</span> <span lang="en" dir="ltr" class="mw-content-ltr">In the {{ll|Extension:WikiEditor|nsp=0}} with {{ll|Help:Extension:TemplateWizard|nsp=0}}, as in the other editors, it displays the parameter automatically when a user inserts the template, but the parameter cannot be removed using this or any editor.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It also does not display <code>{{int|Visualeditor-dialog-transclusion-required-parameter-description}}</code> in the parameter description; rather, it lists the parameter on the side under <code>{{int|templatewizard-parameters-required}}</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Other than this, it generally behaves the same as in the other editors, except that the prompt says that the input doesn't "match the expected format".</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">In the visual editor and the 2017 wikitext editor, the <code>"deprecated"</code> status does not override the functionality of this parameter, but in the 2010 wikitext editor with TemplateWizard it does.</span> <span lang="en" dir="ltr" class="mw-content-ltr">See the description of <code>"deprecated"</code> for more info.</span> | <syntaxhighlight lang="javascript"> "required": true </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|suggested|Suggested}} |- ! suggested | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"suggested"</code> parameter can be set to either <code>true</code> or <code>false</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">When unspecified it defaults to <code>false</code>.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> Use <code>"suggested"</code> for parameters that are not mandatory but strongly recommended for template users to provide. When filling in this parameter, a user will see this suggestion. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">In the visual editor and the {{ll|2017 wikitext editor}}, it causes the parameter to automatically show up when a user inserts a template.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If the parameter has an autovalue set, this will also automatically be in the parameter's input box.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It has no other effect and doesn't show any additional text or warnings.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In the {{ll|Extension:WikiEditor|nsp=0}} with TemplateWizard, it does not place the parameter in the template automatically but instead causes it to be listed on the side under <code>{{int|templatewizard-parameters-suggested}}</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The user can then click a "+" next to the parameter to add it to the template.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"required"</code> status overrides the functionality of this status in all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor).</span> <span lang="en" dir="ltr" class="mw-content-ltr">It also overrides the displayed <code>"suggested"</code> status in template data documentation (it will display <code>"required"</code> if both <code>"required"</code> and "suggested" are set to <code>true</code>).</span> | <syntaxhighlight lang="javascript"> "suggested": true </syntaxhighlight> |- style="visibility:collapse" | colspan="3" | {{anchor|deprecated|Deprecated}} |- ! deprecated | <span lang="en" dir="ltr" class="mw-content-ltr">Finally, there is <code>"deprecated"</code>, which can be set to <code>true</code>, <code>false</code>, or a string describing what users should instead do.</span> <span lang="en" dir="ltr" class="mw-content-ltr">When unspecified it defaults to <code>false</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This is a status for parameters that should not be used any more but still exist for the time being.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This could be because uses of the template are being moved from one set of parameters to another.</span> '''<span lang="en" dir="ltr" class="mw-content-ltr">Effects</span>''' <span lang="en" dir="ltr" class="mw-content-ltr">The effect of this parameter in the visual editor and the 2017 wikitext editor is that a grey exclamation mark shows next to the parameter's label when it is inserted, and in the parameter's information tooltip, the grey, italic text "{{int|Visualeditor-dialog-transclusion-deprecated-parameter-description|''deprecation reason''}}" is shown below the parameter description.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It does not affect the functionality or usability of the parameter or show any additional warnings.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Despite the fact that it can take a string, as of January 2020 none of the main editors (the visual editor, the 2017 wikitext editor or the 2010 wikitext editor) display the contents of the string anywhere to users.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Inputting a string has the same effect as <code>true</code>.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> In the 2010 wikitext editor with TemplateWizard, setting this value as <code>true</code> does not allow the parameter to be added or seen. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> If you set both this and <code>"suggested"</code> as <code>true</code>, the parameter status will show as <code>"deprecated"</code> in the template data documentation, but in the visual editor and the 2017 wikitext editor both functionalities will be retained; the parameter will automatically show up when a user inserts a template, but it will have the <code>"deprecated"</code> warnings around it. </div> <span lang="en" dir="ltr" class="mw-content-ltr">If you set both this and <code>"required"</code> as <code>true</code>, the parameter status will show as "deprecated" in the template data documentation, but in the visual editor and the 2017 wikitext editor it will have the same functionality as only <code>"required"</code>; the parameter will automatically show up when a user inserts a template, and it will have the <code>"required"</code> warnings around it.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This is the same for if you set <code>"deprecated"</code>, <code>"suggested"</code> and <code>"required"</code> as <code>true</code>.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> In the 2010 wikitext editor with TemplateWizard, <code>"deprecated"</code> overrides the parameters <code>"required"</code> and <code>"suggested"</code>. </div> |<syntaxhighlight lang="javascript"> "deprecated": "Please use 'publicationDate' instead." </syntaxhighlight> |- |} <div lang="en" dir="ltr" class="mw-content-ltr"> Note: if neither <code>"required"</code>, <code>"suggested"</code> nor <code>"deprecated"</code> are set as <code>true</code> for a parameter, its status will show as <code>"optional"</code> in the template data documentation. </div> <span lang="en" dir="ltr" class="mw-content-ltr">Once you're done, hit <code>{{int|templatedata-modal-button-saveparam}}</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If you've made errors, it will not let you save (which is disruptive but means you can't break anything).</span> <span lang="en" dir="ltr" class="mw-content-ltr">Should you run into errors, explain on the [[Special:MyLanguage/VisualEditor/Feedback|feedback page]] what you were trying to do, and we will be happy to help.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> Note that if you are abusing a hack template to dynamically generate template data, it cannot be checked for errors before saving. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Note that each item of information is enclosed in quotation marks (except for <code>true</code> and <code>false</code>) and separated from the next item by a comma (unless it's the last one). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===== Type parameter ===== </div> <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"type"</code> parameter is meant to signal to a template editor the nature of a parameter's value.</span> <span lang="en" dir="ltr" class="mw-content-ltr">In some cases, template editors have been programmed to modify the user interface for a certain parameter according to this template data value, such as to only allow the user to enter valid values that match the specified type.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This parameter does not have any functional effect on the template parameter or its value; it merely controls how template editors see and treat the parameter in editing mode.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''How to use''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> It is used by adding the <code>"type"</code> parameter, followed by a colon and a space, then adding any of the values listed in the table below in quotation marks. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Example: </div> <syntaxhighlight lang="javascript"> "type": "string", </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> As of February 2020, only 5 of the 13 type values have visible effects in VisualEditor and the 2017 wikitext editor, while 8 have visible effects in TemplateWizard. </div> <span lang="en" dir="ltr" class="mw-content-ltr">The effects of certain values are likely to change as the template editors get updates to support them.</span> <span lang="en" dir="ltr" class="mw-content-ltr">One such effort for VisualEditor and the 2017 wikitext editor is tracked in the Phabricator task [[phab:T55613|T55613]].</span> <span lang="en" dir="ltr" class="mw-content-ltr">A similar effort to get TemplateWizard to support the boolean value is tracked in [[phab:T200664|T200664]].</span> <div lang="en" dir="ltr" class="mw-content-ltr"> The currently known effects are listed as follows. </div> {| class="wikitable" |+ {{Anchor|Type parameter table}} ! style="width: 10%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Value</span> ! style="width: 90%;"| <span lang="en" dir="ltr" class="mw-content-ltr">Description</span> |- style="visibility:collapse" | colspan="3" | {{anchor|unknown|Unknown}} |- ! unknown | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"unknown"</code> value is the default type value if no type is set.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It can also be set manually by typing <code>"type": "unknown"</code>.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> In all main editors (VisualEditor, 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"unknown"</code> has no visible effects compared to a template without template data. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|string|String}} |- ! string | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"string"</code> value is intended for any string of plain text. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"string"</code> has no visible effect compared to <code>"unknown"</code>. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|line|Line}} |- ! line | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"line"</code> value is intended for content that should be forced to stay on one line. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> * <span lang="en" dir="ltr" class="mw-content-ltr">In the visual editor and the 2017 wikitext editor, <code>"line"</code> prevents a parameter's input box from allowing new lines, which are usually possible in these editors.</span> * <span lang="en" dir="ltr" class="mw-content-ltr">In the 2010 wikitext editor with TemplateWizard, <code>"line"</code> has no visible effect (input boxes do not allow new lines by default in this editor).</span> |- style="visibility:collapse" | colspan="3" | {{anchor|content|Content}} |- ! content | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"content"</code> value is intended for wikitext of page content, for example, links, images or text formatting. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"content"</code> has no visible effect. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"content"</code> makes the parameter input box one line taller and allows new lines, which regular input boxes in the 2010 wikitext editor do not. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|unbalanced-wikitext|Unbalanced-wikitext}} |- ! {{nowrap|unbalanced-wikitext}} | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"unbalanced-wikitext"</code> value is intended for wikitext that cannot stand alone, i.e. it lacks an opening or closing tag or refers to other parts of wikitext. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"unbalanced-wikitext"</code> has no visible effect. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"unbalanced-wikitext"</code> makes the parameter input box one line taller and allows new lines, which regular input boxes in the 2010 wikitext editor do not. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|wiki-page-name|Wiki-page-name}} |- ! {{nowrap|wiki-page-name}} | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"wiki-page-name"</code> value is intended for a page name on a wiki. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"wiki-page-name"</code> makes the parameter input box show a suggestion dropdown menu containing a list of pages on the wiki, such as articles on Wikipedia, which can be selected.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Namespaces can also be defined in the search.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Additionally, in the visual editor and the 2017 wikitext editor, it forces the input box content to stay on one line.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It has no other visible effect and doesn't prevent a non-page from being inputted.</span> |- style="visibility:collapse" | colspan="3" | {{anchor|wiki-file-name|Wiki-file-name}} |- ! {{nowrap|wiki-file-name}} | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"wiki-file-name"</code> value is intended for a file name hosted either locally on a wiki or on Wikimedia Commons. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"wiki-file-name"</code> has no visible effect. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"wiki-file-name"</code> makes the parameter input box show a suggestion dropdown menu containing a list of files hosted both locally and on Wikimedia Commons, which can be selected. </div> <span lang="en" dir="ltr" class="mw-content-ltr">The file names do not contain the "File:" namespace prefix.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The dropdown menu also shows the thumbnail of the files.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It has no other visible effect and doesn't prevent a non-file from being inputted.</span> |- style="visibility:collapse" | colspan="3" | {{anchor|wiki-template-name|Wiki-template-name}} |- ! {{nowrap|wiki-template-name}} | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"wiki-template-name"</code> value is intended for the name of a template. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"wiki-template-name"</code> makes the parameter input box show a suggestion dropdown menu containing a list of templates, which can be selected.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Additionally, in the visual editor and the 2017 wikitext editor, it forces the input box content to stay on one line.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It has no other visible effect and doesn't prevent a non-template from being inputted.</span> |- style="visibility:collapse" | colspan="3" | {{anchor|wiki-user-name|Wiki-user-name}} |- ! {{nowrap|wiki-user-name}} | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"wiki-user-name"</code> value is intended for a username on a wiki. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <span lang="en" dir="ltr" class="mw-content-ltr">In all main editors (the visual editor, the 2017 wikitext editor and the 2010 wikitext editor with TemplateWizard), <code>"wiki-user-name"</code> makes the parameter input box show a suggestion dropdown menu containing a list of actual users' names, which can be selected.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Additionally, in the visual editor and the 2017 wikitext editor, it forces the input box content to stay on one line.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It has no other visible effect and doesn't prevent a non-username from being inputted.</span> |- style="visibility:collapse" | colspan="3" | {{anchor|number|Number}} |- ! number | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"number"</code> value is intended for numerical values, including negative values and decimals. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"number"</code> has no visible effect. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"number"</code> causes the input box to display a "+" and "-" button on either side, which can raise or lower a number value in the input box, and the user can only type numbers into the box. </div> <span lang="en" dir="ltr" class="mw-content-ltr">The buttons can also lower the number into negatives.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''With other parameters''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"number"</code> overrides the effects of <code>"[[#Autovalue|autovalue]]"</code>; the value of <code>"autovalue"</code> will not be automatically placed in the input box if the parameter type is <code>"number"</code>. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|boolean|Boolean}} |- ! boolean | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"boolean"</code> value is intended for a value that is either true, false or unknown.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This is intended by the [[Special:MyLanguage/Extension:TemplateData#Param object|manual]] to be represented by a "1", "0" or blank value.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> With the <code>autovalue:0</code> checkbox appears in the visual editor, which can be switched on and off. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|date|Date}} |- ! date | <span lang="en" dir="ltr" class="mw-content-ltr">The <code>"date"</code> value is intended for a date in the YYYY-MM-DD ([[:en:ISO 8601|ISO 8601]]) format; for example, 2014-05-22.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The [[Special:MyLanguage/Extension:TemplateData#Param object|template data manual]] also designates it as being intended for ISO 8601 date–time combinations, such as "2014-05-22T16:01:12Z", but in practice no major editing interface as of February 2020 uses it in this fashion, and almost all major Wikimedia template parameters take dates and times separately.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"date"</code> has no visible effect. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"date"</code> makes the parameter input box about a third shorter and adds a dropdown calendar, allowing the user to choose a date input. It also displays the grey example text in the input box "YYYY-MM-DD". If an input does not conform to this standard, the box glows red, however the editor will always output a date conforming to the standard (if numbers are entered) or nothing (if only text or nothing is entered). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''With other parameters''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"date"</code> overrides the effects of <code>"[[#Autovalue|autovalue]]"</code>; the value of <code>"autovalue"</code> will not be automatically placed in the input box if the parameter type is <code>"date"</code>. </div> |- style="visibility:collapse" | colspan="3" | {{anchor|url|Url|URL}} |- ! url | <div lang="en" dir="ltr" class="mw-content-ltr"> The <code>"url"</code> value is intended for a URL, with Internet protocol (e.g., "https://" or "//") included. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> '''Effects''' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"url"</code> makes the input box display an external link icon (a square with arrow pointing out of it) in the left hand side of the box and makes the box glow red when the user clicks away without entering a URL value that includes a valid Internet protocol (e.g., "https://", "ftp://" or "//") followed by some text. </div> <span lang="en" dir="ltr" class="mw-content-ltr">This second effect is similar to that of the "<code>[[#Required|required]]</code>" setting, but it does not warn the user if they attempt to insert the template without a valid URL.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It also occurs with any status setting (such as "<code>[[#Suggested|suggested]]"</code>" or "<code>[[#Deprecated|deprecated]]</code>").</span> <div lang="en" dir="ltr" class="mw-content-ltr"> * In the 2010 wikitext editor with TemplateWizard, <code>"url"</code> has no visible effect. </div> '''<span lang="en" dir="ltr" class="mw-content-ltr">With other parameters</span>''' <div lang="en" dir="ltr" class="mw-content-ltr"> * In the visual editor and the 2017 wikitext editor, <code>"autovalue"</code> overrides the visible effects of <code>"url"</code>: when both are set, the input box will not contain a URL icon nor glow red when the user clicks away without entering a valid URL. </div> |} {{anchor|Custom formats}} === <span lang="en" dir="ltr" class="mw-content-ltr">Custom formats</span> === <div lang="en" dir="ltr" class="mw-content-ltr"> When editing the <code>"format"</code> value, you create custom formats by inputting a set of wikitext symbols using some predefined rules. </div> * <code><nowiki>{{</nowiki></code> - <span lang="en" dir="ltr" class="mw-content-ltr">start of the template</span> * <code><nowiki>_</nowiki></code> - <span lang="en" dir="ltr" class="mw-content-ltr">content (e.g., string, integer or parameter).</span> <span lang="en" dir="ltr" class="mw-content-ltr">This underscore serves to indicate the minimum length of a value in characters and can be repeated, like <code><nowiki>_______</nowiki></code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">If this length is not reached, it fills the remaining characters with spaces.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This can be used to align all equals signs to a specific position after a parameter (if used with <code>\n</code> for new lines).</span> * <code><nowiki>|</nowiki></code> - <span lang="en" dir="ltr" class="mw-content-ltr">pipe (separates parameters)</span> * <code><nowiki>=</nowiki></code> - <span lang="en" dir="ltr" class="mw-content-ltr">equals sign (precedes the value of a parameter)</span> * <span lang="en" dir="ltr" class="mw-content-ltr"><code>\n</code> or pressing the enter key - new line (this will display as <code>↵</code> in the entry field)</span> * <code><nowiki> </nowiki></code> - <span lang="en" dir="ltr" class="mw-content-ltr">space (can be used with <code>\n</code> to indent new lines)</span> * <code><nowiki>}}</nowiki></code> - <span lang="en" dir="ltr" class="mw-content-ltr">end of the template</span> <div lang="en" dir="ltr" class="mw-content-ltr"> The wikitext should at least meet the minimum of <code><nowiki>{{_|_=_}}</nowiki></code>, otherwise there will be an invalid format string error. </div> {| class="wikitable" |+ <span lang="en" dir="ltr" class="mw-content-ltr">Examples of formats you can use</span> ! style="width:25%" | <span lang="en" dir="ltr" class="mw-content-ltr">Objective</span> ! <span lang="en" dir="ltr" class="mw-content-ltr">Format string</span> ! <span lang="en" dir="ltr" class="mw-content-ltr">Output</span> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Inline formatting</span> | <code style="white-space: pre-wrap;"><nowiki>{{_|_=_}}</nowiki></code> <br/> <code>inline</code> | <pre>{{Foo|bar=baz|longparameter=quux}}{{Bar}}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Block formatting</span> | <code style="white-space: pre-wrap;"><nowiki>{{_\n| _ = _\n}}</nowiki></code> <br/> <code>block</code> | <pre>{{Foo | bar = baz | longparameter = quux }}{{Bar}}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">No space before the parameter name, each template on its own line</span> | <code style="white-space: pre-wrap;"><nowiki>\n{{_\n|_ = _\n}}\n</nowiki></code> | <pre>{{Foo |bar = baz |longparameter = quux }} {{Bar}}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Indent each parameter</span> | <code style="white-space: pre-wrap;"><nowiki>{{_\n |_ = _\n}}</nowiki></code> | <pre>{{Foo |bar = baz |longparameter = quux }}{{Bar}}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Align all parameter names to a given length</span> | <code style="white-space: pre-wrap;"><nowiki>{{_\n|_______________ = _\n}}\n</nowiki></code> || <pre>{{Foo |bar = baz |longparameter = quux |veryverylongparameter = bat }} {{Bar}}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Pipe characters at the end of the previous line</span> | <code style="white-space: pre-wrap;"><nowiki>{{_|\n _______________ = _}}</nowiki></code> | <pre>{{Foo| bar = baz| longparameter = quux}}{{Bar}}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Inline style with more spaces, must be at start of line</span> | <code style="white-space: pre-wrap;"><nowiki>\n{{_ | _ = _}}</nowiki></code> | <pre>{{Foo | bar = baz | longparameter = quux}} {{Bar }}</pre> |- | <span lang="en" dir="ltr" class="mw-content-ltr">Template at the start of a line, indent-aligned parameters, pipe beforehand</span> | <code style="white-space: pre-wrap;"><nowiki>\n{{_ |\n _______________ = _}}</nowiki></code> | <pre>{{Foo | bar = baz | longparameter = quux}} {{Bar}}</pre> |} <div lang="en" dir="ltr" class="mw-content-ltr"> === Blank boilerplate === </div> <div lang="en" dir="ltr" class="mw-content-ltr"> You can copy the blank boilerplate below to add new template data to a template. Only the most common tags are included. </div> <syntaxhighlight lang="javascript"> <templatedata> { "description": "", "params": { "1": { "label": "", "description": "", "type": "" }, "2": { "label": "", "description": "", "type": "" } } } </templatedata> </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Errors== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === {{int|templatedata-invalid-parse}} / Bad JSON format === </div> <div lang="en" dir="ltr" class="mw-content-ltr"> These errors occur when saving template data, usually manually edited, with invalid JSON code (duplicate keys/parameters, trailing or missing commas, etc.) in the visual editor or the 2017 wikitext editor. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <code>{{int|templatedata-invalid-parse}}</code> appears in the visual editor and the 2017 wikitext editor; "Bad JSON format" appears when editing in the template data GUI editor. </div> <span lang="en" dir="ltr" class="mw-content-ltr">These errors can be difficult to detect and come in too many forms to list.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The best way to avoid them is to edit template data exclusively with the template data editor; the best way to detect them once they've occurred is to use an external JSON validator, such as [[#jsonlint|JSONLint]], which will highlight errors and aid in fixing them.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The 2010 wikitext editor does not check for invalid JSON thanks to an old, unfixed bug ({{phab|T128029}}).</span> <span lang="en" dir="ltr" class="mw-content-ltr">Pages that contain invalid JSON may throw alarming <code>{{int|internalerror}}</code> messages.</span> <span lang="en" dir="ltr" class="mw-content-ltr">To fix these errors, your best bet is to use a JSON validator (see above).</span> {{anchor|Required property}} === {{int|templatedata-invalid-missing|2=paramOrder[<var><span lang="en" dir="ltr" class="mw-content-ltr">number</span></var>]}} === <span lang="en" dir="ltr" class="mw-content-ltr">This error occurs if you state a parameter in <code>"[[#Params|params]]"</code> that is not stated in <code>"[[#ParamOrder|paramOrder]]"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The number in the square brackets refers to the parameter in <code>"paramOrder"</code> that is missing.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It refers to its order in the sequence, but it is one less than its actual position, since <code>"paramOrder"</code> is an array; 0 is the first one, 1 is the second, etc.</span> <syntaxhighlight lang="javascript"> "params": { "date": { ... }, "reason": { ... }, "talk": { ... // <-- This parameter is not stated in "paramOrder", but it should be. } }, "paramOrder": [ "date", "reason" ] // Error: Required property "paramOrder[2]" not found. </syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">To fix this, make sure all parameters stated in <code>"params"</code> are listed in <code>"paramOrder"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Alternatively, you can remove the <code>"paramOrder"</code> object to remove this error.</span> === {{int|templatedata-invalid-value|2=paramOrder[<var><span lang="en" dir="ltr" class="mw-content-ltr">number</span></var>]}} === <span lang="en" dir="ltr" class="mw-content-ltr">This error occurs if you state a parameter in <code>"[[#ParamOrder|paramOrder]]"</code> that is not stated in <code>"[[#Params|params]]"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">The number in the square brackets refers to the parameter in <code>"paramOrder"</code> that shouldn't be there.</span> <span lang="en" dir="ltr" class="mw-content-ltr">It refers to its order in the sequence, but it is one less than its actual position, since <code>"paramOrder"</code> is an array; 0 is the first one, 1 is the second, etc.</span> <syntaxhighlight lang="javascript"> "params": { "date": { ... }, "talk": { ... } }, "paramOrder": [ "date", "reason", // <-- This parameter is not stated in "params", but it should be. "talk" ] // Error: Invalid value for property "paramOrder[1]". </syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">To fix this, make sure all parameters stated in <code>"paramOrder"</code> are listed in <code>"params"</code>.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Alternatively, you can remove the <code>"paramOrder"</code> object to remove this error.</span> === {{int|templatedata-invalid-type|2=params.<var><span lang="en" dir="ltr" class="mw-content-ltr">parametername</span></var>.required|3=boolean}} === <div lang="en" dir="ltr" class="mw-content-ltr"> This error occurs if you put quotation marks around the value of either <code>"[[#Required|required]]"</code> or <code>"[[#Suggested|suggested]]"</code>. </div> <syntaxhighlight lang="javascript"> "suggested": "true" // <-- These quotation marks shouldn't be here. </syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">These are boolean values, not strings, therefore they require no quotation marks.</span> <span lang="en" dir="ltr" class="mw-content-ltr">To fix this, remove any quotation marks around the values <code>true</code> or <code>false</code> for these parameters.</span> <div lang="en" dir="ltr" class="mw-content-ltr"> === Property "format" is expected to be ... === </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If the <code>"[[#Format|format]]"</code> parameter exists but its value is not <code>"inline"</code>, <code>"block"</code> or a valid format string, you will see the error message <code>{{int|Templatedata-invalid-format|format}}</code>. </div> <syntaxhighlight lang="javascript"> "format": "notinline" // Error : Property "format" is expected to be "inline", "block", or a valid format string. </syntaxhighlight> <span lang="en" dir="ltr" class="mw-content-ltr">To fix this, make sure the value after <code>"format": </code> equals <code>"inline"</code> or <code>"block"</code> and that there no spelling mistakes.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Alternatively, if it's wikitext, make sure it contains a minimum of <code><nowiki>{{_|_=_}}</nowiki></code> and that there are no mistakes in the syntax that would normally cause a template to fail, such as duplicate equals signs or missing/duplicate curly brackets; see the section [[#Custom formats|#Custom formats]] for the syntax for custom formats.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Alternatively, you can remove the <code>"format"</code> parameter to remove this error.</span> {{anchor|Unexpected property}} === {{int|templatedata-invalid-unknown|2=<var><span lang="en" dir="ltr" class="mw-content-ltr">parametername</span></var>}} === <span lang="en" dir="ltr" class="mw-content-ltr">This error occurs if you state a parameter that is unknown in template data.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This is probably due to spelling mistakes or the use of uppercase letters instead of lowercase.</span> <syntaxhighlight lang="javascript"> <templatedata> { "description": "", "format": "inline", "params": { "1": { "label": "", "descriptino": "", // <-- spelling mistake "type": "" } } } </templatedata> </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> It also occurs if you state a parameter in any template data object that is not a parameter of that object. This may be due to spelling mistakes, or you may have written the parameter of one template data object under another object that it doesn't belong to. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> For example, you might have written the parameter <code>"[[#Label|label]]"</code> under the root template data object instead of inside <code>"[[#Params|params]]"</code>: </div> <syntaxhighlight lang="javascript"> <templatedata> { "description": "", "format": "inline", "label": "", // <-- incorrectly placed parameter "params": { "1": { // ↓ it should be in here "description": "", "type": "" } } } </templatedata> </syntaxhighlight> <div lang="en" dir="ltr" class="mw-content-ltr"> Alternatively, if the unexpected parameter is under a template parameter inside <code>"params"</code>, you'll see its name after "params.''parametername''." in the error. </div> <span lang="en" dir="ltr" class="mw-content-ltr">To fix this, make sure there aren't any spelling mistakes in the parameter names, and make sure your parameters are in their correct location.</span> <span lang="en" dir="ltr" class="mw-content-ltr">Additionally, make sure you don't state any parameters that don't exist for a template data object.</span> <span lang="en" dir="ltr" class="mw-content-ltr">You can check which parameters exist for an object in the section [[#Template data parameters|#Template data parameters]].</span> === {{int|templatedata-invalid-missing|params}} === <span lang="en" dir="ltr" class="mw-content-ltr">This error occurs if there is no <code>"[[#Params|params]]"</code> object in the template data.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This is a necessary object, as it contains all the details of each parameter, so to fix this error, make sure it's added and that there are no spelling mistakes.</span> <span lang="en" dir="ltr" class="mw-content-ltr">See [[#Params|the section above]] on how to add the <code>"params"</code> parameter.</span> {{anchor|Limitations and questions}} <div lang="en" dir="ltr" class="mw-content-ltr"> == Limitations and feedback == </div> * '''<span lang="en" dir="ltr" class="mw-content-ltr">Missing features</span>''' – <span lang="en" dir="ltr" class="mw-content-ltr">Template data is an example of a tool that was made available with few features, in hope that users would help to guide development of features that they desired. If you'd like to request new features for template data, please [https://phabricator.wikimedia.org/maniphest/task/edit/form/102/?projects=MediaWiki-extensions-TemplateData let us know].</span> * '''<span lang="en" dir="ltr" class="mw-content-ltr">Delays in showing in templates</span>''' – <span lang="en" dir="ltr" class="mw-content-ltr">After adding template data to a template, the metadata should be visible immediately when the template is opened in the visual editor. However, it is possible that it will take several hours before the metadata will show. You can force an update by making a null edit to the template page itself (not the documentation subpage). To perform a null edit, open the template page for editing, and save the page ''without making any change and without adding any edit summary''.</span> * '''<span lang="en" dir="ltr" class="mw-content-ltr">Current issues</span>''' – <span lang="en" dir="ltr" class="mw-content-ltr">A list of current bugs and feature requests is available [[phabricator:maniphest/query/qXa9bowMj3nX/#R|in the Wikimedia bug tracker]].</span> <div lang="en" dir="ltr" class="mw-content-ltr"> == Other tools == </div> ; {{ll|Help:Extension:TemplateWizard}}: <span lang="en" dir="ltr" class="mw-content-ltr">A toolbar dialog window for entering template wikitext via a form built from template data.</span> ; [http://tools.wikimedia.pl/~mlazowik/templatedata/ TemplateData Wizard]: <span lang="en" dir="ltr" class="mw-content-ltr">A tool that generates template data through an interactive interface.</span> ; [[w:User:Salix alba/TDSkell|Skeleton TemplateData generator]]: <span lang="en" dir="ltr" class="mw-content-ltr">A tool that reads the source wikicode of a template, tries to find all the parameters used and outputs a skeleton document with the parameters listed.</span> ; {{anchor|jsonlint}}[https://jsonlint.com/ JSONLint]: <span lang="en" dir="ltr" class="mw-content-ltr">A tool that allows you to validate manually-written JSON to help find errors in the syntax.</span> * <span lang="en" dir="ltr" class="mw-content-ltr">[{{fullurl:Special:PagesWithProp|propname=templatedata&propname-other=}} List of all templates with template data] on this wiki</span> * <span lang="en" dir="ltr" class="mw-content-ltr">With [[w:de:Template:TemplateData|dewiki template template data]]: template data is shown in a box, and the template is added to a [[w:de:category:Vorlage:mit_TemplateData|category]] of templates with template data</span> * <span lang="en" dir="ltr" class="mw-content-ltr">https://query.wikidata.org/ and [[d:Wikidata:SPARQL query service/Query Helper|Query Helper]]</span>
Search
Search
Export translations
Add topic