Module talk:Params

Latest comment: 12 days ago by Uzume in topic growth and sandboxes

{{#invoke:params|self}} edit

I have added a new function to the module, {{#invoke:params|self}}, however I am not sure whether the most idiomatic name for it is self or title (especially considering that self has a special meaning in Lua). --Grufo (talk) 00:36, 27 September 2023 (UTC)Reply

@Grufo: I would prefer a different naming. Based upon magic words like {{PAGENAME}} and friends, things along the lines of PARENTNAME, TEMPLATENAME (sadly we already have a {{TEMPLATENAME}} with a slightly different meaning), INVOKERNAME or similar come to mind, along with the possibilites of things like CHILDNAME, MODULENAME, INVOKEENAME or similar; potentially with modifiers for other encodings a la {{PAGENAMEE}} and comparison of page title encodings, etc. (e.g., by returning mw.title:partialUrl() or similar), not to mention other options in line with things like {{FULLPAGENAME}}, {{FULLPAGENAMEE}}, etc. That said, perhaps those names are not really the best either and it would be better to stick to naming closer to Scribunto naming along the lines of parentPageTitle/modulePageTitle and stick to modifiers provided by mw.title object and/or mw.url API like partialUrl, queryEncode, pathEncode, wikiEncode, anchorEncode. Incidentally, I have often considered developing a Scribunto replacement for base (or even all the extensions in the default and/or WMF MediWiki packaging) magic words and then potentially extending it from there. This begs the need for these types of things more generally but I digress. —Uzume (talk) 19:51, 6 March 2024 (UTC)Reply

Wrapper template with pass-thru params edit

I'm a template writer and have newly discovered this Module, and am still getting on board with it, but have not used it yet. I think it probably will handle some use cases I have, but I'm not quite sure. One case that is typical for me, is a wrapper template with "pass-thru params", that is, the case of a wrapper template A, that calls template B passing thru all or almost all of A's params to B without alteration, and one or two more params with hard-coded values. For a concrete example, consider template {{sfnlink}}. I want to create new wrapper template {{sfnlinknb}}, that will have the identical params that sfnlink has, less param |nb=; the job of the wrapper, is to pass through all of its params to {{sfnlink}}, and add |nb=yes as well. The "pass-thru" part of this seems like the kind of thing I ought to be able to do with Module:Params, but I'm not quite sure. Maybe using for_each? Thanks, Mathglot (talk) 00:09, 3 December 2023 (UTC)Reply

It looks like you have a working implementation using double transclusion and for_each in {{sfnlinknb}} already, but if it's useful as an alternative approach, I just used concat_and_call to do the same thing in {{autnum plain}}: Special:Diff/1188117126. DefaultFree (talk) 13:26, 3 December 2023 (UTC)Reply
DefaultFree, thank you so much for this. Your solution is infinitely better, and I've rewritten my wrapper using your idea. I had made multiple attempts—you can see the numerous failures at the history of User:Mathglot/sandbox/Templates/params_for_each and at Template:Sfnlinknb. At one point, I thought I had it because it worked perfectly at Special:ExpandTemplates, but then I found it didn't work anywhere else—it spit out the correct code (as if it were nowiki'ed), but didn't invoke it, except at ExpandTemplates, for some reason. Then I went off on a tangent, trying to add {{Eval}} in front of the whole thing to get it to execute, and as you saw, I got tangled up in double transclusion, and, oh, what a mess! Yours is so much better, and would make a great addition to the documentation of this Module, either as an example, or as a "Pro tip" note. (You might be interested to see what I did with the (on-page) /doc, the /sandbox, and the /testcases pages for {{Sfnlinknb}}.) Thanks again, and I owe you one! Mathglot (talk) 22:29, 3 December 2023 (UTC)Reply

15th January 2024: New changes edit

The Module:Params/ChangeLog subpage now keeps the record of the most important changes in the module's code. Furthermore four new modifiers – mapping_values_by_calling, mapping_values_by_invoking, mapping_values_blindly_by_calling and mapping_values_blindly_by_invoking – were recently added to the module. These allow to pass each argument one by one to a custom template or a custom module in order to be preprocessed before further actions. --Grufo (talk) 04:07, 15 January 2024 (UTC)Reply

growth and sandboxes edit

Hi @Grufo: - following on from your request over at WP:PERM. Got a few questions:

  1. Do you know what has recently caused the large growth in calls to this module? Is such a large use necessary?
  2. This module doesn't appear to have a /sandbox; now that it is so heavily used where are changes being validated prior to deployment?

Thanks, — xaosflux Talk 13:34, 22 April 2024 (UTC)Reply

xaosflux, the drastic usage increase looks to be due to Special:Diff/1214727698. Primefac (talk) 13:42, 22 April 2024 (UTC)Reply
Numbers should start falling, I've undone the above. Primefac (talk) 13:50, 22 April 2024 (UTC)Reply
FYI to @Uzume:xaosflux Talk 14:19, 22 April 2024 (UTC)Reply
@Xaosflux: Thanks for the heads-up. I just fixed a minor documentation bug. Using something like this module insulated it from potential moves (or someone copying it for as a template, etc.) but there are obviously other ways to fix that issue and I certainly did not mean for it to have such ramifications (I would not want to prevent the author from development; the sandbox still allows such if somewhat more cumbersome). —Uzume (talk) 14:31, 22 April 2024 (UTC)Reply
Hi Xaosflux. I have no idea. I tried to find out, but I believe that whoever is responsible for the growth did not follow the suggestion of adding {{Lua}} to the documentation of the templates that start using this module. So finding out where all the calls come from is hard (btw, someone has to improve the “What links here” special page and allow to list direct transclusions only…). I had planned some important improvements for this module, but I have been very busy in the last months. And as soon as I had a bit of time for the module I found out that I can no longer edit it. Concerning the sandbox: it's not hard to create one, is it? So far every time I posted an update I tested it locally on my machine, but I agree that it would be good to have a sandbox here too. EDIT. Primefac gave the answer while I was writing mine (@Primefac: Thank you). --Grufo (talk) 13:48, 22 April 2024 (UTC)Reply
Always happy to help. For the record, I used an insource search to find where it was being invoked, specifically insource:/invoke:params/, as seen here. Primefac (talk) 14:19, 22 April 2024 (UTC)Reply
I've lowered the protection level on this, you should be able to edit again. Suggest you build up a sandbox and incorporate it to the testcases. — xaosflux Talk 14:21, 22 April 2024 (UTC)Reply
Thank you both @Primefac and @Xaosflux! The next changes in the code will pass through a sandbox. --Grufo (talk) 14:30, 22 April 2024 (UTC)Reply