Extension talk:TemplateData

About this board

Will noincluding TemplateData still keep it in VisualEditor?

2
Andre601 (talkcontribs)

I was wondering if wrapping the TemplateData in noinclude tags will result in it not being displayed within the template page, but still be included within the visual editor.

I want to have a more visually appealing documentation on the main template page while also having the template data present. Sadly, the fact that TemplateData can't render wiki text makes it not a great option for me to use here, so I would like to use this aproach, if doable.

Tacsipacsi (talkcontribs)

TemplateData blocks apply to template pages they’re included in. This means that you can (and should) put it in a <noinclude> block on the template page to avoid it appearing everywhere the template used, but you cannot put it in a <noinclude> on the /doc subpage to avoid it appearing on the template page itself. You can, however, put it in a collapsible box or even completely hide it with style="display:none" (but you should completely hide it only if it’s ensured that equivalent content appears, e.g. with a template like de:Vorlage:TemplateData, since otherwise people wanting to improve the documentation will have a hard time finding it and especially previewing their modifications).

Reply to "Will noincluding TemplateData still keep it in VisualEditor?"

displaying actual template and not the values

5
Timmysworld (talkcontribs)

I created a template using templatedata and used it in my user profile page, unfortunately the page i created doesnt show the values I used for the template.

Thiemo Kreuz (WMDE) (talkcontribs)

I'm afraid there is not much we can do without knowing anything. Which wiki? Which profile page? Which template? I can only suspect that the template doesn't actually accept the parameters, despite the TemplateData documentation saying otherwise.

Timmysworld (talkcontribs)

ok in my Template:Infobox person:

<templatedata>

{

"description": "A template to gather user information for user profile page",

"params": {

"User": {

"label": "Full Name",

"description": "User first and last name",

"type": "string",

"required": true

},

"Department": {

"label": "Department",

"description": "The department in which user currently work",

"type": "string",

"required": true

},

"Unit": {

"label": "Unit",

"description": "The unit in which a user is attached to",

"type": "string",

"required": true

}

}


}


</templatedata> and in my User:Admin I am calling the template Infobox person and specified the values. but the same chart that generated from the template data is generating on the Admin page.

This post was hidden by Thiemo Kreuz (WMDE) (history)
Thiemo Kreuz (WMDE) (talkcontribs)

As said, I don't really know how I can help. Who is "User:Admin"? What "chart"? What is "generated", and where? Which wiki is this about?

TemplateData doesn't "generate" anything. It's just documentation. A template that contains nothing but documentation doesn't do anything.

Reply to "displaying actual template and not the values"

"Params" but "Param object"

9
W like wiki (talkcontribs)
Thiemo Kreuz (WMDE) (talkcontribs)

I agree it's not very easy to understand, but I'm not sure what you are missing. "sets": [] is an array of set objects. A single set object is described below.

Same for "params": {}, except it's not an array but an object that maps parameter names to param objects.

"maps": {} is documented a little different, as a single thing. The descriptions and examples are correct, as far as I can see.

W like wiki (talkcontribs)

Ok Thiemo, thanks for your answer! So Params and sets end in "s" because it is the plural and can contain several parameterS and setS. The "s" in maps is not because there are several maps but because "it maps" something (3rd person), right!?

Thiemo Kreuz (WMDE) (talkcontribs)

"maps" also contains a set of map objects. I updated the text a bit to hopefully make it a bit more clear.

W like wiki (talkcontribs)

Ok, thx Thiemo! Your edits helps, but for maps I still try to find the logic (I am not a programmer, my view is more the one of someone who tries to understand), so:

Thiemo Kreuz (WMDE) (talkcontribs)

Do you plan to work with Citoid or another tool that relies on maps? I find that maps are best understood when approached from that side.

W like wiki (talkcontribs)

No, i found here because I was working on the doc page of C:Template:TemplateBox and I am generally interested in good doc or help pages, and here for me it is still not clear. In chapter "TemplateData object" it is explained:

"Maps (Structure) containing map objects"

so both are different but map objects links to the chapter called Maps Structure. So which of both is described there? Not so clear. Thx

Thiemo Kreuz (WMDE) (talkcontribs)

I really don't know what else I could add. "maps" is a single data structure that goes multiple levels deep. The first level lists consumers by name. The next level lists parameters as they are known by the consumer and maps them to one (as a string) or more (as an array) parameters as they are named in the template.

The consensus seems to be to call the second level in this data structure a "map object".

Not really related, but if you are interested in helping others a good place to start is to convince the community that cryptic parameter names like "1d" or "1sv" are an entirely unnecessary barrier.

W like wiki (talkcontribs)

Ok thank you! I think thats make it clear. I posed a short introduction to the section with your point, I think that also helps others.

And yes, "1d" and "1sv" are really short, I agree with you, was not my creation and I have not the rights to make such big changes for a so widely used template. But in commons many widely used templates using very short parameter names.

My point to make it better (and not having the rights to change the parameter names) is to place comments into a second copy-paste-form (>>my work), because the auto-generated one don't offers this. So if you can help, to introduce this oportunity to TemplateData to place help comments for the parameters in the autogenerated copy-paste-template would be very helpfull! Beste Grüße!

Reply to ""Params" but "Param object""

Do we need this? or can we improve?

3
W like wiki (talkcontribs)

Hello, the question is a bit provocant, I know, but

1) On Commons e.g. there is Commons:Template:TemplateBox which shows a similar table like this extension but with possible links (or wiki markup like italic or code). People like writing descriptions like they are used to (with links, wiki markup,...). Now it is a lot of work, just to write a second version of this description so that all the tags are not visible and the links too. Do we need this Sisyphus work? For Example in Commons:Template:F/doc

| 2d-en  = [[#Display Name|Any text]], default is the file name (parameter #1). If there is no alternate text the parameter #2 instead can hold the first [[#option|option]].
| 2d-td-en = Any text, default is the file name (parameter #1). If there is no alternate text parameter #2 instead can hold the first "option".

2) For a good and helpful parameter description it can help a lot to state a link to another example or to a help pages with more regarding informations. This is not possible with this TemplateData Extension. (see also #How to enable wikitext within descriptions?)

PS.: I think it is the problem with the unsupported wiki markup that led to separate templateBox templates on Commons or other wikis. Normally a unified centralized solution is much better I think but when it has this important weakness, people find their own way and now on Commons the Extension:TemplateData is just collapsed (not visible first) because of the reasons above. Best Regards --W like wiki (talk) 17:20, 10 February 2024 (UTC)

Wargo (talkcontribs)

These data are mostly needed for tools such as VisualEditor to provide help during inserting templates. The solution with hidden TemplateData may be good if you have another template to display parameters, and you can generate it automatically to not duplicate work.

W like wiki (talkcontribs)

Ok @Wargo, thank you for the answer! Yes, VisualEditor for TemplateData is fine! The Automatic generation does not work, because the templates accepting wiki mark up, template data not. What do you think, will it be possible somewhen or will it never work to integrate wiki markup? I don't like dublicate work. Best Regards --~~~~

Reply to "Do we need this? or can we improve?"

Add undocumented parameter not shown

2
Role-end (talkcontribs)

MW version: 1.41

I have a template where I use a loop to iterate over all parameters with a certain name (opt1, opt2, ...). The opt1 is a optional parameter and is shown translated. If someone would like to add more options they just have to add an undocumented parameter with opt2,opt3, and so on. This is working without any problems. But since the update to V1.41 until there are no undocumented parameters added, the buttonlink with "add undocumented parameters" is not shown.

The hotkey for adding is working so pressing ctrl+shift+D will make the link visible. After adding a new undocumented parameter the link stays visible.

I am not sure if this is a topic related to the TemplateData Extension or the VisualEditor.

Tacsipacsi (talkcontribs)
Summary by Thiemo Kreuz (WMDE)

Works but makes it impossible to use the editor.

Meowcatx (talkcontribs)

The doc says:

"Note that  you cannot use {{#tag:templatedata}} in lieu of <templatedata>."

Why not? Works just fine for me, and was also the solution for a problem below.

(Topic:Wlc9a95pueut4dd6)

Thiemo Kreuz (WMDE) (talkcontribs)

TemplateData editor and paramOrder

3
Summary by Thiemo Kreuz (WMDE)

Fixed in more recent versions.

MLRodrigue (talkcontribs)

I have a template that I created in MW 1.31 (TemplateData 0.1.2). The TemplateData editor does not create the paramOrder object, but the order still works, because it adheres to the order in which the parameters are defined in the source code.

However, in my MW 1.35 this no longer works. The params are ordered based on their name instead. Since the editor does not create the paramOrder, I now have to manually add it in the source code for each template. I would like to avoid that and don't know if it's just an issue in my wiki that the paramOrder object is not created automatically by the editor?

Thiemo Kreuz (WMDE) (talkcontribs)

I wasn't involved back then and can't tell when this broke, and where. It's potentially related to an unrelated change in Parsoid. But I'm aware of this issue. We fixed it just recently via gerrit:700350. This is part of MediaWiki 1.37, but not earlier, unfortunately. I think the best option you have (other than using 1.37) is to add a specific paramOrder to each template. The TemplateData editor isn't designed to do this automatically.

MLRodrigue (talkcontribs)

Okay, then I know what to do. Thanks for the prompt answer!

Pull values from the TemplateData block?

2
Summary by Thiemo Kreuz (WMDE)

Unclear request, suggest to use the API.

BCreegan (talkcontribs)

I would like to create a DPL that lists all the templates in a category, along with the description listed inside their data block. Is this possible?

Thiemo Kreuz (WMDE) (talkcontribs)

TemplateData not working in Nepali Wiki

6
Summary by Thiemo Kreuz (WMDE)

Works again.

बडा काजी (talkcontribs)

We recently change document subpage from "/doc" to "/कागजात"; now the TemplateData seems to be not working anymore. In other wiki it seems to work but not in Newiki.

Thiemo Kreuz (WMDE) (talkcontribs)

I'm afraid there is a lot of information missing. What changed? What doesn't work? Do you have an example link? One thing I can see is that ne:MediaWiki:Templatedata-doc-subpage still says "doc".

Whatamidoing (WMF) (talkcontribs)

Is this still broken?

Whatamidoing (WMF) (talkcontribs)

DannyS712, is this a problem that gets fixed by a config change?

बडा काजी (talkcontribs)

It seems to be working now

DannyS712 (talkcontribs)

No idea, sorry

$wgExtraNamespaces breaks the button?

4
Summary by Celyn Kendrick

It seems to be ok if I put the custom namespaces at the bottom of the LocalSettings.php. Maybe an order/race thing.

Celyn Kendrick (talkcontribs)

I've added a custom namespace, and the $wgExtraNamespaces[NS_FOO] = "Foo"; line in LocalSettings.php seems to break it so that the "Manage Template" button and "Information about Template Data" at the top of the editor pages don't show up. I've tried commenting out different additions to the LocalSettings.php to see what breaks it, and it's definitely localized to these two lines (Namespace and Talk Namespace).

Advice?

Thiemo Kreuz (WMDE) (talkcontribs)

I had a look at the code but unfortunately don't have an advice. The button appears exclusively in the Template namespace. Namespaces settings shouldn't affect it. Do you see error messages in the browser's JavaScript console?

Celyn Kendrick (talkcontribs)

[ZAoPZeU7uGrffEJTmVYQEwAAAYI] 2023-03-09 16:55:02: Fatal exception of type "InvalidArgumentException" (anonymous) @ load.php?lang=en&modules=startup&only=scripts&raw=1&skin=monobook:4

Tested it, and it only appears when I've got extra namespaces uncommented.

Celyn Kendrick (talkcontribs)

It seems to be ok if I put the custom namespaces at the bottom of the LocalSettings.php. Maybe an order/race thing.