Help talk:TemplateData

About this board

Previous discussion was archived at Help talk:TemplateData/Archive 1 on 2015-09-04.

BoldLuis (talkcontribs)

Why do not automatically appear parameters when editing templates in Wiktionary (using the "Edit Template Data" button, in the left corner when editing the template)?

Thiemo Kreuz (WMDE) (talkcontribs)

What exactly are you trying to edit?

Reply to "Wiktionary"

Don't list the contents in the form of tables

3
SolidBlock (talkcontribs)

I find in this page, there are many tables to show the usage of parameters. I don't think using table is a preferred way. It is hard to read and unfriendly in mobile views.

For example:

parameterdescriptionexample
aliasesdescription of aliases<syntaxhighlight>...</syntaxhighlight>

The better way to present content may be:

=== aliases ===
description of aliases

Example:
<syntaxhighlight>...</syntaxhighlight>
Whatamidoing (WMF) (talkcontribs)

TemplateData is stored in machine-readable JSON, and I think that JSON might create the tables.

Tacsipacsi (talkcontribs)

The complaint is not about TemplateData, but about the wikitext page Help:TemplateData – to be exact, about Help:TemplateData#Template data parameters. (By the way, even if it was about TemplateData itself – JSON doesn’t create tables, it’s just a format for storing data. Those tables are created by PHP code that was programmed to create tables, but which could just as well be programmed to create definition lists or whatever format we want.)

Reply to "Don't list the contents in the form of tables"
GhostInTheMachine (talkcontribs)

Many of the examples under the "Custom formats" section show two parameters that are 3 characters long – bar and qux. Please can the examples be adjusted to use both a short and a long parameter name — GhostInTheMachine talk to me 14:23, 31 August 2023 (UTC)

Jonesey95 (talkcontribs)

Done. Good idea.

Suggestion of a new Custom format for fullwidth characters

5
Pikakapi (talkcontribs)

Hello, this extension is very useful to use, but there is one problem in fullwidth characters.

Fullwidth characters use two space, so I can't make a custom format that all parameters align in same length.

Tacsipacsi (talkcontribs)

Actually, fullwidth characters aren’t exactly two spaces wide, at least not using my font (DejaVu Sans Mono). In the below example, I tried to use two spaces per fullwidth character, and the four spaces are wider than the two letters:

{{Template
|ABC= 
|A    = 
}}

Given this, I’m not sure how feasible such a format would be. In any case, feature requests should be raised on Phabricator if you want them to be noticed by developers.

Pikakapi (talkcontribs)

Thank you for letting me know.

I'm use to my wiki's font which fullwidth = 2 spaces, so I forgot about that.

Whatamidoing (WMF) (talkcontribs)

Pikakapi, what languages do you write in?

Pikakapi (talkcontribs)

Korean

Reply to "Suggestion of a new Custom format for fullwidth characters"
BoldLuis (talkcontribs)

All TemplateData would include a link to Wikidata.

Whatamidoing (WMF) (talkcontribs)

Why?

185.127.147.131 (talkcontribs)

Because can be used in other projects.

BoldLuis (talkcontribs)

Without retyping all the data, fields an information.

Whatamidoing (WMF) (talkcontribs)

I don't think I understand your suggestion. This is the TemplateData for the English Wikipedia's "citation needed" template:

<templatedata>
 {
 "description": "The template is used to identify claims in articles, particularly if questionable, that need a citation to a reliable source.",
 "params": {
 "date": {
 "label": "Month and year",
 "description": "Provides the month and year of the citation request; e.g., 'January 2013', but not 'jan13'",
 "type": "string",
 "autovalue": "{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}",
 "suggested": true
 },
 "reason": {
 "label": "Reason for citation",
 "description": "A reason as to why, or for what content, the citation is needed; use single quotes, if any",
 "type": "string"
   }
  }
 }
 </templatedata>

No editor or reader at any article ever sees that. I don't think it makes any sense to add a Wikidata link to the TemplateData.

Are you looking for a sort of magic infobox, so that you can type {{infobox}} and Wikidata fills in all the fields for you? That already exists, and it has nothing to do with TemplateData. Have a look at w:es:Jimmy Wales for an example of a long infobox that is mostly pulled from Wikidata.

BoldLuis (talkcontribs)

From your example : "description": "The template is used to identify claims in articles, particularly if questionable, that need a citation to

It would be translated to other language, I e. Spanish:

"description": "La plantilla se usa para identificar afirmaciones en artículos (and so on...)

So, this translation into Spanis of the template can be used in Wiktionary in Spanish, Wikipedia in Spanish, Wikibooks in Spanish... Translate once, use in several places.

On the other hand, this is seen in a forms way, when editing TemplateData.

BoldLuis (talkcontribs)

TemplateData editor method

This is the simpler way to add or edit TemplateData, possible for inexperienced users. </translate>

The TemplateData editor is a graphical user interface for adding and editing TemplateData. It is part of the TemplateData extension. It is accessible by going to any template's page (or documentation subpage) and clicking "Edit" or "Edit source".

After clicking "Edit" or "Edit source", you will see a button above the editing area and page title that says "Manage TemplateData".

Clicking this button will enter the TemplateData editor. If the page you are on already contains TemplateData, this will automatically show here. A screenshot of the TemplateData editing tool

Whatamidoing (WMF) (talkcontribs)

Because we don't have Global templates, it's unlikely that anything would get re-used in multiple places.

BoldLuis (talkcontribs)

We can use TemplateData in Wikidata for templates in all sister projects and so, the template documentation can be reused in multiple sister projects. Translate once, reuse several times. Also could be used the Wikifunctions wiki.

This post was hidden by Tacsipacsi (history)
Reply to "Wikidata"

Help with finding TemplateData's with errors

3
Shushugah (talkcontribs)

I recently fixed TemplateData on en:Template:Infobox organization but did not find an easy way to search for other potentially affected templates with errors, particularly high trafficl ones. Is there a tracking category for this? Shushugah (talk) 19:09, 13 September 2021 (UTC)

Whatamidoing (WMF) (talkcontribs)
Izno (talkcontribs)

If by "fixed TemplateData" Shushugah means this set of edits, no, there is no way to detect this.

Reply to "Help with finding TemplateData's with errors"

TemplateData in user space?

9
Summary last edited by ExE Boss 00:33, 5 November 2021 2 years ago
Vexations (talkcontribs)

I've tried to add TemplateData to a template in my user space, but couldn't get it to work. To make sure the problem wasn't with my template, I copied an existing one that worked on enwp {{0}}, and found that it stopped working when I tried to place the TemplateData in User:username/templates/template/doc. Does TemplateData only work in the Template namespace? Thanks, ~~~~

ExE Boss (talkcontribs)

Note that you also need to transclude the documentation subpage into the User template page for it to work, e.g.: {{m:User:ExE Boss/OtherProjects}}.

Vexations (talkcontribs)

Thanks, yes, that's a good point, but I think I had that right: immediately at the end the last line of the template, I called had the documentation template embedded in a noinclude tag. The working template that I copied also did that, but stopped working in user space.

ExE Boss (talkcontribs)

Right, I forgot to mention, that you also need to perform a null edit/hard purge of the User template page, in order to properly update the templatedata page property (the TemplateData  extension does this automatically in the Template namespace when editing the doc[1] subpage).

References

Jonesey95 (talkcontribs)

It is always helpful to link to an example page when you are asking for technical help.

Vexations (talkcontribs)

Thanks for helping everyone! It's fairly easy to reproduce: Copy the 0 template (I just chose that because its one of the first in the list of templates that use TemplateData) and its doc subpage to your userspace. Now try to edit your sandbox with the Visual Editor and add the 0 template. My version that demonstrates the problem is at en:User:Vexations/templates/PB

Tacsipacsi (talkcontribs)

It doesn’t work in VisualEditor indeed, but it seems to be a bug in VE, not TemplateData: when I open your user subpage’s talk page in VisualEditor and try to insert the user subpage, no TemplateData is provided (and not even the title is visible in the autocomplete for the template name), while if I use the wikitext editor’s template inserter , it works perfectly.

Whatamidoing (WMF) (talkcontribs)

Pinging @Johanna Strodt (WMDE), because this is probably not related to WMDE's work on templates in VisualEditor, but it might be useful to know about anyway.

Johanna Strodt (WMDE) (talkcontribs)
Reply to "TemplateData in user space?"

Visual Editor corrupts TemplateData-generated transclusions on save, when not using short URL format

4
Summary last edited by Clump 21:59, 2 July 2021 2 years ago

As tracked in the referenced Phabricator bug, the Visual Editor does not support "long" URLs of the form https://site.name/index.php?title=Page_name. Only so-called "short" URLs, e.g. https://site.name/wiki/Page_name, are compatible with Visual Editor.

Bjsdaiyu (talkcontribs)

MW 1.35.0, TemplateData 0.1.2

I have templates defined using TemplateData. Filling in and editing these templtates works fine in Visual Editor (VE) up through the first save, for example this image, but upon subsequent edits it cannot find the template as shown here: it strangely believes that :index.php?title=Template:<Template Name> is the name of the Template page! Any thoughts

FeRDNYC (talkcontribs)

Hmm. A few questions:

  1. What does the "Generated from:" text show in the popup box for the template, when you commit the data edits in the Visual Editor (before you save)?
  2. What does it show after you save, then edit the page again?
  3. If you switch to Source Editing while you're re-editing the page, does it show the correct template transclusion, e.g. {{Cite book|something=|something_else=|...}}
  4. What is the URL format for your wiki? Like, what's the actual URL to Template:Cite book? What's the URL for the article you're editing?

On Wikipedia, Template:Cite book lives at https://en.wikipedia.org/wiki/Template:Cite_book.

So if I'm editing https://en.wikipedia.org/wiki/The_Cat_in_the_Hat and want to cite Dr. Seuss, the URL to Template:Cite Book has the same https://en.wikipedia.org/wiki/ prefix. Same for the article's edit interface, which loads from https://en.wikipedia.org/wiki/The_Cat_in_the_Hat?action=edit

But it looks like either your wiki is using old-style index.php?title= URLs and the Visual Editor is mishandling those, or something is configured to think the URLs should be index.php?title=-style when they're not. (Are there any rewriting rules / HTTP redirects configured on the wiki's web server, for article paths?)

GeoffreyHfr (talkcontribs)

I have the same problem. I just found a bug logged pointing at the no-usage of Short URL :

https://phabricator.wikimedia.org/T270219


They give some workaround.

I have just added $wgUsePathInfo=true; to my LocalSettings.php for it to work.

FeRDNYC (talkcontribs)

Ooh, good find @GeoffreyHfr, that bug clearly describes exactly the problem here. According to the info there, Visual Editor simply doesn't support index.php?title= URLs, period. Apparently it never has, since Wikipedia has used short URLs since long before Visual Editor became a thing.

(Might be nice if that was documented somewhere prominent, or if it had some way to detect those URLs and at least display a helpful error message. Still, at least now people have this bug to refer to, so that's something.)

Reply to "Visual Editor corrupts TemplateData-generated transclusions on save, when not using short URL format"
קיפודנחש (talkcontribs)

so, wiki template syntax supports something called #switch.

the switch can have a "default", or not. when a parameter is _only_ used in a switch, and there is no "default", it means that only one of the suggested values will have any effect, and everything else is equivalent to no value at all.

the TD syntax should allow distinguishing between those two types of use. currently, the help page says

"If the user needs a value not included in the list (for example, "message in a bottle") they can type it in manually."

this makes sense for some parameters, and no sense for others (i.e., params only used in #switch with no default).

note that the TD is used by things other than the visual editor, for which this feature was requested for the longest time - see, e.g., phab:T224342.

peace

Tacsipacsi (talkcontribs)
Reply to "suggestedvalues"

Documenting Lua modules

4
Summary by 197.218.87.157
Adamw (talkcontribs)

Will TemplateData be used to document Lua? Can VisualEditor use TemplateData to give hints for module invocation?

Whatamidoing (WMF) (talkcontribs)

Are you meant to be invoking a module directly?

Adamw (talkcontribs)

Good point, thanks! There's already a /doc subpage (e.g. [1]) for the module itself, and that's all we need.

It's the functions within a module which can be invoked from wikitext, these take parameters, and this is where we would need the structured documentation. I'm not sure how we could provide these docs (or maybe editors feel this is not lacking?). LDoc and maybe other syntaxes would be appropriate for inlining docs in the source code, but wouldn't cover our use case. We pass an opaque frame and it's the args arguments within that define the module's MediaWiki interface. We also need a way to indicate which functions are meant to be public.

Needless to say, however we (if we) decide on a syntax, it should be machine-parsable so it can be leveraged by VisualEditor and other tools.

Reply to "Documenting Lua modules"