Jump to content

Help talk:TemplateData/Archive 2

About this board

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

Don't list the contents in the form of tables

6
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.)

Daask (talkcontribs)

I know of two common ways the TemplateData in JSON format is converted to HTML:

  1. The default provided by Extension:TemplateData in TemplateDataHtmlFormatter.php (Phabricator Diffusion, GitHub)
  2. w:en:Template:Format TemplateData.

It totally possible to write a new template/module to parse the JSON and produce the format that SolidBlock suggests (or any other format). That's exactly what w:en:Module:Format TemplateData does, so start by just replacing its its features function.

I'm not sure if SolidBlock's concern was with the specific page Help:TemplateData as Tacsipacsi suggests, or with TemplateDataHtmlFormatter.php's output in general. However, if it's a readability issue on this page, then it's surely a readability problem elsewhere as well.

Tacsipacsi (talkcontribs)

However, if it's a readability issue on this page, then it's surely a readability problem elsewhere as well.

Not necessarily, as most tables on this page aren’t generated by TemplateDataHtmlFormatter.php. Compare the first table of Help:TemplateData#Template data parameters with the TemplateData table at the bottom of the preceding section – the former is gigantic both vertically and horizontally (it definitely has a readability problem), and thus hard to use even on desktop, while the TemplateData table – which is what appears on other pages as well – is completely fine on desktop, and mostly usable on my phone as well (so I wouldn’t say it has a readability problem).

Daask (talkcontribs)

Oh, my mistake, Tacsipacsi is certainly right. Thus my above comments, while true, are irrelevant.

How to test custom format strings

2
Daask (talkcontribs)

How can I test the output of custom formats? Obviously, it's possible to do it like this:

  1. Create or edit a template with some TemplateData
  2. Save the page
  3. Create or edit another page that invokes the template, using the visual editor or some other automated tool that uses TemplateData.
  4. Switch to the wikitext editor from the visual editor.
  5. Observe the output.
  6. Repeat steps 1-5 for any other custom formats you'd like to try.

That's really tedious.

Tacsipacsi (talkcontribs)

Steps 3 and 4 can be merged if you switch from the visual editor to Extension:TemplateWizard (available on all WMF wikis), which works directly in the wikitext editor. It doesn’t support editing existing template transclusions, but it supports adding all parameters with a single click and then inserting the template, which should be enough for this kind of task.

I don’t know of an even quicker way, although I think it should be possible to write a gadget (or build a feature into TemplateData itself) that renders a transclusion with all parameters based on the currently-edited TemplateData block.

Reply to "How to test custom format strings"

teaching the case 'no parameter'

5
Summary by Wladek92

ok stored in the description.

Wladek92 (talkcontribs)

when the template has parameters I can fill the array of templatedata => ok

but when all parameters are optionnal i cannot indicate it in the template data since a parameter name is always mandatory. How can i inform this case ?

thanks. --Christian 🇫🇷 FR (talk) 08:21, 5 April 2024 (UTC)

Thiemo Kreuz (WMDE) (talkcontribs)

I'm not exactly sure what the problem is, but I suspect you want "params": {}.

"Optional" parameters – i.e. parameters that are neither required nor suggested – shouldn't be a problem.

Wladek92 (talkcontribs)

that is for need to describe the defaut behaviour of the template when no parameter is provided. Where to put this information in the template data ?

Ponor (talkcontribs)

"description": "..." perhaps?

Wladek92 (talkcontribs)
Summary by Wladek92

wrong user syntax. done.

Vestrian24Bio (talkcontribs)

Hi! I tried creating a TemplateData here; But I couldn't save it due to the "Syntax Error in JSON" so, I kept it as a coding for now; could someone please review it and tell me how to fix it.

Jonesey95 (talkcontribs)

If you follow the "help" link, it takes you to a page that links to https://jsonlint.com/ which is a helpful tool.

Vestrian24Bio (talkcontribs)
Wladek92 (talkcontribs)

Invalid JSON! Error: Parse error on line 80: ...quired": true }, } "description": "P


^

Expecting 'STRING', got '}'

=> remove the ',’

Wladek92 (talkcontribs)

Hi, i just try to use a template update adding french wordings. It is ok. I recommend to use the template data button at the top of the frame. It opens graphic web interface and make the declarations for you automatically rather than to update/copy the source text manually which becomes complicated as more indentations occur. No obvious error were detected in this tool so that your Json error is probably comming from wrong syntax. --Christian 🇫🇷 FR (talk) 06:11, 23 May 2024 (UTC)

Suggestion of a new Custom format for fullwidth characters

5
Summary by Thiemo Kreuz (WMDE)

Not possible due to consistent behavior across operating systems, fonts, and the software used.

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

Summary by Thiemo Kreuz (WMDE)

Not enough information. The template data is probably on a /documentation subpage.

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?

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.

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 3 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?"