#REDIRECT [[Wikipedia talk:TemplateData]]
If there is a discrete set of valid values for a parameter, e.g. collapse="yes"/"no", where do we tell the user which choices they've got? The "string" doesn't give them many pointers. --[[User:99of9|99of9]] ([[User talk:99of9|talk]]) 21:58, 28 June 2013 (UTC)
:The description, ideally :). [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 22:29, 28 June 2013 (UTC)
== "default" tag ==
I discovered that there is an additional tag, "<code>default</code>", that shows the default value for the template parameter. Example:
<pre>
<templatedata>
{
"description": "Description of the template",
"params": {
"1": {
"label": "Label of the parameter",
"description": "Description of the parameter",
"type": "string",
"required": true,
"default": "Default text of this parameter"
}
}
}
</templatedata>
</pre>
It is not mentioned in this tutorial, but it is listed in the TemplateData table that is produced. Are we supposed to be using it yet? '''[[User:The Anonymouse|The Anonymouse]]''' ([[User talk:The Anonymouse|talk]]) 13:58, 29 June 2013 (UTC)
:Yeah, using it is fine - it's just not necessary, so I tried to strip the tutorial down to "things that are required", basically :). [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 15:08, 29 June 2013 (UTC)
::OK, thanks! '''[[User:The Anonymouse|The Anonymouse]]''' ([[User talk:The Anonymouse|talk]]) 04:32, 30 June 2013 (UTC)
== More useful debugging output needed ==
{{tracked|50511}}
This system is really not usable without better debugging. I just spent over an hour creating 200 lines of TemplateData for [[Template:Infobox disease]], and when I try to save it, all I get is "JSON syntax error". I'm not going to use this system until it does a better job of pinpointing errors, or at least giving some clue about the type of error. (If anybody is interested in trying to spot the syntax error, I saved my work as a comment in [[Template:Infobox disease/doc]].) [[User:Looie496|Looie496]] ([[User talk:Looie496|talk]]) 16:27, 1 July 2013 (UTC)
:I agree we need better debugging commentary; actually, I'm unable to find a bug with that. {{Ping|Adavidb}}? [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 17:14, 1 July 2013 (UTC)
::There was a double-quote symbol missing from the end of the "label" entry for the "eMedicineSubj" parameter. Such syntax errors are very difficult to catch with visual review alone. I commented out various parts of the code to narrow down where the error was. The corrected version remains commented, for any additional changes before activation. —[[User:Adavidb|ADavidB]] 18:05, 1 July 2013 (UTC)
:::Thanks. I've uncommented it and saved it -- appears to work. I still think I'm going to wait until there are more informative error messages before making further use of this system. Regards, [[User:Looie496|Looie496]] ([[User talk:Looie496|talk]]) 18:26, 1 July 2013 (UTC)
::::Seems reasonable; I've added a bug for it. [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 18:42, 1 July 2013 (UTC)
== Should be hidden when empty, and always link to documentation ==
I just discovered the existence of this after an IP editor added it to [[Template:Colon/doc]]. I have two observations: firstly, the displayed output needs to link to the TemplateData documentation (perhaps link "Template parameters"), otherwise it's virtually inexplicable - I had to perform a help namespace search to find it. Secondly, if empty it should either be hidden or a message along the lines of "this template does not take any parameters" should be shown. At present it just produces a clumsy-looking empty table, as in the example above.
This isn't meant to be negatively critical of the implementation, I know it's very early days yet. — [[User:Scott Martin|'''<span style="color:#000">Scott</span>''']] <span style="color:#900">•</span> [[User talk:Scott Martin|''<span style="color:#000">talk</span>'']] 12:07, 2 July 2013 (UTC)
::Good points, both :). I'm not sure how we'd handle the first one - what do we do with localisation, for example? - but we can look into it. [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 12:58, 2 July 2013 (UTC)
== Placement ==
The section [[Wikipedia:VisualEditor/TemplateData tutorial#TemplateData]] implies that it doesn't matter if {{tag|TemplateData}} is added to the /doc page or to the main template page. I would suggest that the {{tag|TemplateData}} should be placed on the /doc page wherever possible, since if it's put on the template, it'll add pages to the [[Help:Job queue|job queue]] unnecessarily (see [[bugzilla:50372]] and [[WP:VPT#TemplateData: Is it working?]]). --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 16:25, 3 July 2013 (UTC)
:Fair point; I'll make sure it's tweaked when we update the documentation (being written now). [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 15:09, 5 July 2013 (UTC)
== Parameters in example ==
The order of parameters in the "Str left"-example is reversed. In Templatedata (and the step by step instruction) "string" should come first, then "count". They are unnamed parameters, the current order won't work or would return wrong results. [[User:GermanJoe|GermanJoe]] ([[User talk:GermanJoe|talk]]) 14:43, 5 July 2013 (UTC)
:Oh, darn :(. We're actually about to update the tutorial :). [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 15:09, 5 July 2013 (UTC)
::Fixed the template [[Template:Str_left]] for now ;). [[User:GermanJoe|GermanJoe]] ([[User talk:GermanJoe|talk]]) 07:45, 9 July 2013 (UTC)
:::Thanks! :D. I need to start making a list of names (in a "free cookies" way, not in a PRISM way) [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 08:13, 9 July 2013 (UTC)
== Editor for TemplateData ? ==
Hi, is there any editor tool for TemplateData on enwiki ? On frwiki, a user made a [[:fr:Utilisateur:Ltrlg/scripts/TemplateDataEditor.js|script]] which allows creating/updating the {{tag|templatedata}} visually and very easily. Anyone willing to make the same for enwiki ? --[[User:NicoV|NicoV]] <sup>([[:fr:Discussion Utilisateur:NicoV|Talk on frwiki]])</sup> 08:42, 16 July 2013 (UTC)
:Ooh. I'd love if someone could take and translate that. [[User:Okeyes (WMF)|Okeyes (WMF)]] ([[User talk:Okeyes (WMF)|talk]]) 13:35, 16 July 2013 (UTC)
::I posted a request on [[Wikipedia:WikiProject User scripts/Requests]]. --[[User:NicoV|NicoV]] <sup>([[:fr:Discussion Utilisateur:NicoV|Talk on frwiki]])</sup> 16:39, 16 July 2013 (UTC)
== Had a go - feedback ==
I've just tried adding TemplateData to {{tl|EW charity}} on its /doc page - not one of the commonest templates, but one I know and understand as I wrote it. But I don't know whether I've done it right, and from the sound of it there's a 60-hour delay before I can look at its effect. Hmm, not ideal.
Comment on the tutorial: you don't explain what to do for an optional parameter (ie that "required" can be omitted, which seems to be the case, rather than needing to be set to "false"). I also wasn't very clear what I was supposed to be putting in the various fields - perhaps if I use more templates with templatedata it will start to make more sense.
I don't like being offered a choice without any indication which is preferred or why: please indicate the "best" or "standard" place to put the TemplateData (template page or /doc page) - and it might be helpful to standardise mildly on whether it goes at top or bottom of the /doc page, if that's the better page for it to be. Unnecessary choices are hard work: just tell us where to put the TemplateData.
In the list of heavily used templates, I noted that {{tl|hatnote}} is marked up as "done". I wanted to have a look at the effects, as it's a template with no named parameters, just one locational parameter. Editing my sandbox I clicked to transclude "Hatnote"... and got no information about the parameters, just the usual "Add parameter" and "No unused parameters" - not what I expected. Looking at [http://en.wikipedia.org/w/index.php?title=Template:Hatnote/doc&action=history the history] I see the TemplateData was added on 11 June, 6 days ago. Should something useful be displayed when I try to use the template? I'm struggling rather with all of this as yet. [[User:PamD|<font color="green">'''''Pam'''''</font>]][[User talk:PamD|<font color="brown">'''''D'''''</font>]] 15:59, 17 July 2013 (UTC)
|