W
Active Editors
Back to Profile

User Talk: Grufo

Server-side rendered snapshot of this editor's Wikipedia talk page discussions.

{{User:MiszaBot/config
|archiveheader = {{talk archive navigation}}
|maxarchivesize = 70K
|counter = 4
|minthreadsleft = 4
|minthreadstoarchive = 1
|algo = old(31d)
|archive = User talk:Grufo/Archive %(counter)d
}}
{{archive box|auto=long|age=31|units=days|bot=Lowercase sigmabot III}}

Merging Module:Multiformat ↗ with Module:Params ↗



I created multiformat because (1) I could not figure out how to use Module:Params ↗ for a particular template I was working on, and (2) at the time I forgot params existed. I wanted to know if you could perhaps incorporate some of the functionality in the former module in the latter. I'll also update the references appropriately.

BTW it would be a lot lot easier for readability if there were LDoc tags explaining the different functions. A year or so I adapted Module:Docbunto ↗ for Wikipedia precisely because it supports LDoc. The module is also getting kind of long as well so it probably would be really beneficial to have submodules with subroutines for Module:Params ↗. Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 19:54, 22 May 2026 (UTC)
: Hi Aasim, I tried to understand what {{mfl|Multiformat|main}} and {{mfl|Multiformat|nArgs}} do, but beyond a suspect or maybe a glimpse, I could not figure it out (my suspect is that your module outputs numeric parameters specifying custom separators, a header, and a footer, although I did not get the details). Could you give a concrete example? --Grufo (talk) 22:19, 22 May 2026 (UTC)
:: Oh, I think I got it now. What your module does can already be done by Module:Params ↗. This, for instance is an exact clone of {{Tl|Standard installation}} that uses Module:Params ↗ instead of Module:Multiformat ↗:

{{Collapsed|1=<syntaxhighlight lang="wikitext"><includeonly>{{#switch:{{#invoke:params|excluding_non-numeric_names|count}}
|1={{#ifexist:Template:{{SUBPAGENAME:{{{1|}}}}} standard installation|{{{{SUBPAGENAME:{{{1|}}}}} standard installation|nocat={{{nocat|}}}}}|{{notice|1=Any breaking changes ↗ to this template, including moving it or nominating it for deletion, {{strong|must be communicated in advance}} to }}} ↗, as they are used in the standard installation of {{SUBPAGENAME:{{{1|}}}}}. {{#ifexist:Category:Templates used by {{SUBPAGENAME:{{{1|}}}}}|{{yesno|1={{{nocat|}}}|yes=|no={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=}}}}} ↗}}}}}}}}}}}}
|0=<strong class="error">No script provided!</strong>
|#default={{notice|1={{#invoke:params|
excluding_non-numeric_names|
trimming_values|
with_value_not_matching||strict|
entering_substack|
mapping_to_lowercase|
mapping_by_replacing|awb|autowikibrowser|strict|
with_value_matching|twinkle|strict|
or|ultraviolet|strict|
or|redwarn|strict|
or|autowikibrowser|strict|
detaching_substack|
mapping_by_magic|#switch|
let|twinkle|Twinkle ↗{{yesno|1={{{nocat|}}}|yes=|no={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by Twinkle ↗}}}}}}|
let|ultraviolet|Ultraviolet ↗{{yesno|1={{{nocat|}}}|yes=|no={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by Ultraviolet ↗}}}}}}|
let|redwarn|RedWarn ↗{{yesno|1={{{nocat|}}}|yes=|no={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by RedWarn ↗}}}}}}|
let|autowikibrowser|AutoWikiBrowser ↗{{yesno|1={{{nocat|}}}|yes=|no={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by AutoWikiBrowser ↗}}}}}}|
leaving_substack|
renaming_by_mixing|<<<$#>>>$@|
mapping_by_magic|SUBPAGENAME|
snapshotting|entering_substack|
snapshotting|entering_substack|
mapping_by_mixing|Category:Templates used by $@|
mapping_by_magic|#ifexist|2|!||
with_value_not_matching||strict|
detaching_substack|
dropping_substack|
detaching_substack|
mapping_by_mixing|$@ ↗|
leaving_substack|
mapping_by_mixing|$@ ↗{{yesno|1={{{nocat|}}}|yes={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by $@ ↗}}}}|no={{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by $@ ↗}}}}|
flushing|
mapping_by_replacing|<<<%d+>>>||1|
renaming_by_replacing|^<<<(%d+)>>>.*$|%1|1|
flushing|
all_sorted|
setting|h/i/f|<ul><li>|</li><li>|</li></ul>|
list_values
}}
}}
}}</includeonly><noinclude>
When used with one script:
{{{{PAGENAME}}|Twinkle|nocat=yes}}

When used with one script (fallback):
{{{{PAGENAME}}|Foo|nocat=yes}}

When used with multiple scripts:

{{{{PAGENAME}}|Twinkle|RedWarn|Wikipedia talk:Huggle|nocat=yes}}
{{documentation}}
</noinclude></syntaxhighlight>}}

:: Just some considerations:
::* Module:Params ↗ is as generic as possible, which means that it has many functions that do atomic actions, which then you have to put together like the pieces of a block. The pro is that the module can do a lot of things, the contra is that using Module:Params ↗ is not very different from actual programming (it is still way more synthetic than using plain Lua though)
::* The code above is made longer by the fact that you designed some special actions for particular scripts like Twinkle, RedWarn, Huggle, etc. It is a clone of your code, so I followed verbatim what you did, but personally I would not do that.
:: P.S. As for explaining the different functions, is the documentation not complete enough? If you talk about the inner (private) functions, LDoc tags could work, but it seems a bit of an overkill for that. --Grufo (talk) 23:47, 22 May 2026 (UTC)
:::Okay that may be a bit too complicated for me to understand. I based the formatting of my multiformat module a little bit like how DPL3/4 ↗ works, except there isn't weird formatting like <code>²{Template name¦arg=art}²</code>, or commas between pulled argument names or anything like that. There is also support for things like line breaks in the inputted wikitext and stuff which I could not find in params.
:::The closest I could find was "for_each", but even that isn't too obvious and it does not have any obvious flags listed right there. Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 00:21, 23 May 2026 (UTC)
:::: @Aasim: Yes, doing exactly what you did is complicate in one go (although it isn't if we use subtemplates—see below). But as I said, half of the code above is used for managing the exceptions (Twinkle, RedWarn, Huggle, etc.). If you remove these (e.g. by using links of the type <syntaxhighlight lang="wikitext" inline>... ↗</syntaxhighlight>, which would need to be created as redirects—although I should check our policy concerning cross-namespace redirects), the code gets reduced by half:

{{Collapsed|1=<syntaxhighlight lang="wikitext"><includeonly>{{#switch:{{#invoke:params|excluding_non-numeric_names|count}}
|1={{#ifexist:Template:{{SUBPAGENAME:{{{1|}}}}} standard installation|{{{{SUBPAGENAME:{{{1|}}}}} standard installation|nocat={{{nocat|}}}}}|{{notice|1=Any breaking changes ↗ to this template, including moving it or nominating it for deletion, {{strong|must be communicated in advance}} to }}} ↗, as they are used in the standard installation of {{SUBPAGENAME:{{{1|}}}}}. {{#ifexist:Category:Templates used by {{SUBPAGENAME:{{{1|}}}}}|{{yesno|1={{{nocat|}}}|yes=|no={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=}}}}} ↗}}}}}}}}}}}}
|0=<strong class="error">No script provided!</strong>
|#default={{notice|1={{#invoke:params|
excluding_non-numeric_names|
trimming_values|
with_value_not_matching||strict|
renaming_by_mixing|<<<$#>>>$@|
mapping_by_magic|SUBPAGENAME|
snapshotting|entering_substack|
snapshotting|entering_substack|
mapping_by_mixing|Category:Templates used by $@|
mapping_by_magic|#ifexist|2|!||
with_value_not_matching||strict|
detaching_substack|
dropping_substack|
detaching_substack|
mapping_by_mixing|$@ ↗|
leaving_substack|
mapping_by_mixing|$@ ↗{{yesno|1={{{nocat|}}}|yes={{sandbox other||{{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by $@ ↗}}}}|no={{#switch:{{NAMESPACE}}|{{ns:828}}|{{ns:10}}=Category:Templates used by $@ ↗}}}}|
flushing|
mapping_by_replacing|<<<%d+>>>||1|
renaming_by_replacing|^<<<(%d+)>>>.*$|%1|1|
all_sorted|
setting|h/i/f|<ul><li>|</li><li>|</li></ul>|
list_values
}}
}}
}}</includeonly><noinclude>
When used with one script:
{{{{PAGENAME}}|Twinkle|nocat=yes}}

When used with one script (fallback):
{{{{PAGENAME}}|Foo|nocat=yes}}

When used with multiple scripts:

{{{{PAGENAME}}|Twinkle|RedWarn|Wikipedia talk:Huggle|nocat=yes}}
{{documentation}}
</noinclude></syntaxhighlight>}}

:::: Moreover, consider that everything above can be made way simpler by using a subtemplate (e.g. {{Tl|Standard installation/script}}) that gets called for each numeric parameter. That will make the code above become as simple as:
:::: <syntaxhighlight lang="wikitext">{{#invoke:params|
excluding_non-numeric_names|
trimming_values|
with_value_not_matching||strict|
all_sorted|
setting|h/i/f|<ul><li>|</li><li>|</li></ul>|
call_for_each_value|Standard installation/script
| nocat = {{{nocat|}}}
}}</syntaxhighlight>
:::: Then {{Tl|Standard installation/script}} will only need to decide what to do with {{param|1}} and {{param|nocat}} (which will also make it easy for you to manage the exceptions).
:::: There can be many solutions to the same problem using Module:Params ↗. I think your module can also be a possible approach to these kinds of problems, but the risk is that with all these <syntaxhighlight lang="wikitext" inline>{{((}}</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline>{{))}}</syntaxhighlight>, etc. the code becomes less readable. As for understanding the code, you have to think that (most of) the lines above are written in the form <syntaxhighlight lang="wikitext" inline>modifier|argument 1|argument 2|...|argument N|</syntaxhighlight> (e.g. <syntaxhighlight lang="wikitext" inline>renaming_by_replacing|^<<<(%d+)>>>.*$|%1|1|</syntaxhighlight>), and each modifier has its own chapter in the documentation. --Grufo (talk) 01:20, 23 May 2026 (UTC)
::::: @Aasim: See {{Tl|Standard installation/sandbox}} and {{Tl|Standard installation/sandbox/script}}. --Grufo (talk) 01:46, 23 May 2026 (UTC)
::::::Yeah, it would be nice to have a solution that does not rely on creating external templates to call repeatedly.
::::::I'm going to argue that it is probably better to simplify the module so that a handful of entry points handle the majority of cases. You can always create another module that extends the base behavior, but this has to be something with very little learning curve. Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 03:05, 23 May 2026 (UTC)
::::::: @Aasim: You shouldn't worry about performance. Module:Params ↗ is well optimized, and your {{Tl|Standard installation}} already calls a few templates for each parameter (e.g. {{tl|yesno}}, {{tl|sandbox other}}), {{tl|!((}}, {{tl|!}}}}, etc.). If you look at the numbers under “Parser profiling data” they are pretty much the same for the two approaches. Personally I like the modularity of relying on a subtemplate, especially if you have to maintain a database of special scripts that will likely grow over time (Twinkle, RedWarn, Huggle, etc.). As for reducing the functions of Module:Params ↗, it is heavily used in other wikis (particularly Latin Wikipedia heavily depends on it), and so that it is not possible, I am afraid. On English Wikipedia however it is usually used in its most basic form (having the possibility of creating complex scripts does not require that you do that). I agree with you that mastering the module in full requires a long read of the documentation. Most people however start with minimal hacks and get to like the nuances slowly over time. --Grufo (talk) 05:06, 23 May 2026 (UTC)
::::::::{{talk quote inline|As for reducing the functions of Module:Params ↗, it is heavily used in other wikis (particularly Latin Wikipedia heavily depends on it), and so that it is not possible, I am afraid.}}
::::::::Then can't those functions just be present on the Latin Wikipedia version of Module:Params ↗? Alternatively, perhaps Module:Params ↗ could be renamed to something such as "Module:Params advanced ↗", keeping all of that advanced functionality in case it is needed, and freeing up Module:Params ↗ as an extremely basic module that is easily editable and expandable. Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 05:36, 23 May 2026 (UTC)
::::::::: Having the same name for different modules across wikis would be a maintenance nightmare. You can try to make Module:Multiformat ↗ keep that approach however. I am not against having more solutions for solving similar problems. P.S. When I designed the module, I deliberately chose never to call <code>frame:preprocess</code> from within Module:Params ↗, because I wanted to avoid things like {{tl|!((}}, {{tl|!}}}}, {{tag|nowiki}}, and so on. The rationale was: if you want to have complex parsable contents, use subtemplates (Module:Params ↗ allows you to call them easily); that will also improve the readability of your code. --Grufo (talk) 05:47, 23 May 2026 (UTC)
{{od|:::::::::}} @Aasim: Earlier you asked me if it is possible to merge Module:Multiformat ↗ into Module:Params ↗. The answer is yes, and it can be done very easily, as easy as this ↗ (which leads to this version ↗ of {{Tl|Standard installation}}). As I said, I have always been against using <code>frame.preprocess()</code>, because it is slow, and the code that the user has to write tends to be ugly. And in fact, it is ugly in the current version of {{Tl|Standard installation}} (which uses Module:Multiformat ↗), as well as in the sandbox version that uses the new experimental directive <code>mapping_by_expanding</code>. It is possible to mitigate the ugliness by using this other escape-based syntax ↗, which you correctly glimpsed in Module:Multiformat ↗, but it is still terrible compared to the nice syntax that uses a subtemplate ↗. What do you think? At the moment I am still mildly averse to including <code>frame.preprocess()</code> into Module:Params ↗, but I am very open to changing my mind. --Grufo (talk) 00:34, 27 May 2026 (UTC)
: P.S. Even without creating <code>...|mapping_by_expanding|...</code>, it has always been possible to reach the same result by writing <code>...|mapping_by_calling|expand wikitext|...</code> (see this other example ↗). --Grufo (talk) 00:44, 27 May 2026 (UTC)

Listing for discussion of :Module:Params ↗


30px|alt=icon ↗ :Module:Params ↗ has been listed for discussion ↗, which may result in the template being merged ↗ or deleted ↗ by consensus ↗. You are invited to comment on the proposed action at '''the entry on the Templates for discussion page''' ↗.<!--Template:Tfdnotice--> Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 18:21, 16 June 2026 (UTC)

:I know this is a bit of a disappointment, but I have to concur that the template is not suitable for En.wiki. It may be more suited for a more tech-oriented wiki like Fandom Developers wiki, though. I do appreciate the hard work that you put in to make the module as robust as possible. Perhaps something simpler and easier to maintain would suffice for English Wikipedia. Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 18:42, 16 June 2026 (UTC)
:: @Aasim: Given the previous discussion, this does not come as a surprise. Let's see what others have to say. --Grufo (talk) 21:11, 16 June 2026 (UTC)
:::I went ahead and forked to Fandom Dev Wiki ↗ where the module perhaps can be refined further, I know it may be a bit of a disappointment that the module is likely to be deleted from English Wikipedia, but perhaps on Fandom (where people already need to learn DPL, and also people are more willing to experiment with formats such as this) it will find a home. Aasim (<ruby>話す<rp>(</rp><rt>はなす</rt><rp>)</rp></ruby> ↗) 02:08, 27 June 2026 (UTC)

Nomination of Template:Link with archives ↗ for discussion


30px|alt=icon ↗ Template:Link with archives ↗, a dependency of this page, has been listed for discussion ↗, which may result in the template being merged ↗, redirected ↗, or deleted ↗ by consensus ↗. You are invited to comment on the proposed action at '''the entry on the Templates for discussion page''' ↗.<!--Template:Tfdnotice--> * Pppery * <sub style="color:#800000">in solidarity</sub> ↗ 17:11, 2 July 2026 (UTC)

Nomination of :Module:Translitteratio ↗ for discussion


30px|alt=icon ↗ :Module:Translitteratio ↗, a dependency of this page, has been listed for discussion ↗, which may result in the template being merged ↗, redirected ↗, or deleted ↗ by consensus ↗. You are invited to comment on the proposed action at '''the entry on the Templates for discussion page''' ↗.<!--Template:Tfdnotice--> * Pppery * <sub style="color:#800000">in solidarity</sub> ↗ 21:52, 2 July 2026 (UTC)