Module talk:TemplateBox

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Extension:TemplateData changes

[edit]

{{Edit request}}

Please apply this diff to Module:TemplateBox in order to ketch up with the latest changes to mw:Extension:TemplateData. -- Rillke(q?) 17:47, 7 October 2014 (UTC)[reply]

✓ Done --Steinsplitter (talk) 08:57, 29 October 2014 (UTC)[reply]

Add support for "autovalue" and "suggestedvalues"

[edit]

{{Edit request}}

Please apply Special:Diff/568352188 to Module:TemplateBox in order to add support for the new "autovalue" and "suggestedvalues" TemplateData fields. —ExE Boss (talk) 20:00, 10 June 2021 (UTC)[reply]

✓ Done, though I changed the tabs to spaces since most of the rest of the module uses spaces --Lucas Werkmeister (talk) 18:37, 11 June 2021 (UTC)[reply]
@Lucas Werkmeister: There’s a typo in the comment on line 6 as of Special:Diff/568547906 now though (argcount( frame )argcoiunt( frame )) —ExE Boss (talk) 18:50, 11 June 2021 (UTC)[reply]
@ExE Boss thanks, fixed ^^ Lucas Werkmeister (talk) 19:18, 11 June 2021 (UTC)[reply]

Hello @ExE Boss and Lucas Werkmeister: I just found this discussion today, I had the same problem and was asking for it here on the doc page of {{TemplateBox}}. Later integrated the autovalue and suggestedvalues into the doc page by my self. Now I tried to use autovalue in the doc page of {{Category}} but it doesn't work. In the green TemplateData box it works fine, but not in the parameter table above, no autovalue displayed there! So where is the problem? (By the way: the parameter type, in this case "line", is also not displayed in the parameter table!) Regards and Thx already! --W like wiki good to know 22:37, 15 February 2024 (UTC)[reply]

The “above table” is the legacy table, which long predates TemplateData: it looked approximately the same in 2009 (and probably actually inspired the TemplateData table). Since it’s exclusively for humans to read, listing autovalue (which is exclusively for machines) doesn’t make sense. It being legacy, it should be removed using |useTemplateData=only wherever possible – in this case, the parameter documentation doesn’t use any fancy wikitext, so it should be possible. —Tacsipacsi (talk) 15:28, 17 February 2024 (UTC)[reply]

Ensure that integer keys are always visited in ascending order

[edit]

{{edit request|technical=1}}

Please apply Special:Diff/568352188/578510343 in order to ensure that even when the numeric parameter indices have holes, then they are enumerated in ascending order, (compare {{TemplateBox}} to {{TemplateBox/sandbox}}). — ExE Boss (talk) 23:00, 4 August 2021 (UTC)[reply]

✓ Done in revision 592378884. — ExE Boss (talk) 08:15, 20 September 2021 (UTC)[reply]

Replacement for obsolete tag.

[edit]

Hello. Can one of administrator change ‎<tt>...‎</tt> to ‎<code>...‎</code> in between 198 and 202? As the ‎<tt>...‎</tt> isn't suitable for HTML5 and will be removed in the future. Thanks. Baris6161TURK (talk) 18:52, 2 January 2022 (UTC)[reply]

@Baris6161TURK: ✓ Done I changed to span tags. NguoiDungKhongDinhDanh 08:00, 5 January 2022 (UTC)[reply]

Add support for "paramOrder"

[edit]

Could we support "paramOrder"? Thanks in advance for any work on this! --Marsupium (talk) 17:59, 11 May 2022 (UTC)[reply]

Autofill of new created template-doc page

[edit]

Hello, if there is a template with no doc page yet (e.g. Template:Multilingual signage) and you choose create the following autotext appears:

<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
{{TemplateBox
  |1        =<!-- Name of the first parameter the template takes -->
  |1label   =<!-- A (very) brief name for the parameter. -->	
  |1d-en    =<!-- English description of the first parameter the template takes -->
  |1d-td    =<!-- description of the first parameter the template takes without any wiki marking-->
  |1aliases =<!-- List of aliases, separated by / (a slash) -->
  |1type    =<!-- number, string, string/wiki-user-name, string/wiki-page-name, string/line; unknown -->
  |1def     =<!-- default value for the parameter -->
  |1stat    =<!-- required, optional or optional-; optional- means it is optional and omitted in the usage-sample -->

  |name               =
  |desc               =
  |namespace          =
  |usergroup          =
  |placement          =
  |example-value      =
  |mustbesubst        =
  |relieson           =
  |usage-notes        =
  |shorthand          =
  |setscats           =
  |seealso            =
  |type               =
  |i18n-desc          =
  |i18n-subpage       =
  |i18n-mediawiki-msg =
  |i18n-method        =
  |example            =
  |print              =
}}
<includeonly>{{Sandbox other||
<!-- Categories below this line; interwikis at Wikidata -->

}}</includeonly>

It's very good that there are short descriptions for the first parameters! I think it would be helpful if there are also such descriptions for the rest of the parameters. For example like this:

{{TemplateBox
 <!-- TEMPLATE PARAMETERS SECTION (for 2nd parameter copy paste & change "1" → "2") -->
 |1          = <!-- parameter name -->
  |1d        = <!-- parameter description (+LANGUAGE CODE) -->
  |1d-td     = <!-- parameter description for TemplateData (+LANGUAGE CODE) -->
  |1label    = <!-- parameter label, very brief, preferably less than 20 characters -->
  |1aliases  = <!-- parameter alternative names that may be used, separated by "/" -->
  |1type     = <!-- parameter type (values: string, number,…) -->
  |1set      = <!-- parameter set ID / Label (to group multiple parameters in a set) -->
  |1def      = <!-- parameter default value (+LANGUAGE CODE) -->
  |1stat     = <!-- parameter status (values: required, optional, optional- or deprecated) -->
 <!-- TEMPLATE SECTION -->
 |useTemplateData    = <!-- expose TemplateData (values: true, export; default: false) -->
 |name               = <!-- template title -->
 |desc               = <!-- template description (+LANGUAGE CODE) -->
 |namespace          = <!-- namespaces, the template is intended to be used (values: all, File, Category,…) -->
 |usergroup          = <!-- usergroup that is meant to use the template (values: all, admin,…) -->
 |placement          = <!-- placement on the page (values: top, bottom, licence or source) -->
 |usage-notes        = <!-- notes about the correct usage of the template -->
 |type               = <!-- template type (values: infobox, formatting, licence tag,…) -->
 |example            = <!-- example value for one (unnamed) parameter -->
 |example-value      = <!-- example use of the template with the value of the example parameter -->
 |i18n-method        = <!-- translation method (values: mediawiki-msg, ext.translate, autotranslate,…)-->
 |i18n-desc          = <!-- translation info -->
 |i18n-mediawiki-msg = <!-- name of the message when using “mediawiki-msg” as method-->
 |i18n-subpage       = <!-- translation subpage when using "ext.translate" as method -->
 |i18n-data-file     = <!-- tabular data file on Wikimedia Commons in the Data namespace -->
 |seealso            = <!-- relevant links (each of them on a new code line with * in the beginning) -->
 |setscats           = <!-- categories which are automatically set by the template -->
 |print              = <!-- template code layout in the #Usage-section (values: one, multi, infobox) -->
 |shorthand          = <!-- redirects to the main template -->
 |relieson           = <!-- list of templates on which the template's basic functionality relies -->
 |mustbesubst        = <!-- set to yes (or any value) if the template must be substituted. -->
 |docsub-page        = <!-- page parameter from {{Documentation subpage}} -->
}}

Regards --W like wiki good to know 00:07, 23 January 2023 (UTC)[reply]

Lua errors

[edit]

This module has some lua errors at template:WLM finalist or winner image/doc. Anybody knows how to fix them? Jarekt (talk) 01:32, 31 December 2023 (UTC)[reply]

More lua errors:
The error on Template:WLM finalist or winner image/doc has nothing to do with TemplateBox. The documentation uses {{Suppress categories}} (in a TemplateBox parameter, hence the module in the stack trace) incorrectly: there are = signs in the parameter value, but there is no explicit |1=.
I found that the script error on Template:MaybeBelowTOO/doc is caused by the |1set= parameter – if I remove it, the error category is gone. I haven’t debugged it further. —Tacsipacsi (talk) 16:20, 31 December 2023 (UTC)[reply]
@Jarekt, Tacsipacsi: I see this "Lua error in Module:JSON at line 255: can't convert function to JSON." issue also on Template:CIL/doc, however it does not seem to show the actual error on the page output (but it is definitely in the HTML source). —Uzume (talk) 04:25, 2 May 2024 (UTC)[reply]
@ExE Boss: Also, putting {{TemplateBox}} into Special:ExpandTemplates allows one to clearly see the error: Script error: The function "TemplateBox/layout <!-- Module:Transclude parameters -->" does not exist.. This appears to directly be caused by 621138876. Module:Transclude is designed to take a page name as the function name of the #invoke, however, it should be noted that although HTML comments are removed from template parameters and arguments and most parser functions use a frame object to do a similar thing, Scribunto does not do such for the #invoke function argument (which are not parsed by the frame). That means the comment gets passed in and ultimately gets passed to mw.title.new() which will return nil (because HTML comments contain characters illegal in MW page titles) causing the __index() metamethod to likewise return the same and ultimately for Scribunto to yield that message about a missing function. —Uzume (talk) 04:25, 2 May 2024 (UTC)[reply]
Uzume, Thank you for looking into it. I have never found where /doc pages call JSON and how to clean up their inputs, which would be the best way to fix it, but I did notice that perturbing wikicode of /doc pages by doing changes that are not suppose to change anything can fix this issue. Your explanation of the cause, make sense. --Jarekt (talk) 12:34, 2 May 2024 (UTC)[reply]
@Jarekt: Well I am still not certain about the Module:JSON#L-255 error. Based upon the error message it is clearly from Module:JSON#L-664 or Module:JSON#L-738 but I haven't managed to track it beyond that yet. Both encode_value() and encode_pretty_value() are called from templatedata() via JSON:encode() and JSON:encode_pretty() depending upon |formatting=pretty and templatedata() gets called via #invoke:TemplateBox both with and without |formatting=pretty from {{TemplateBox}} as arguments (i.e., delayed expansion) to parameters |templateData= and |JSONFM= to {{TemplateBox/i18n}} via #invoke:Languages. I am still investigating. —Uzume (talk) 12:50, 2 May 2024 (UTC)[reply]
Tacsipacsi, I just fixed 4 pages with JSON related Lua errors by removing empty |1set=, |2set= parameters. For example Template:CIL/doc whatever the issue is it seems to be related to those extra parameters. --Jarekt (talk) 04:26, 21 May 2024 (UTC)[reply]