Template talk:Template link general

Trailing pipe symbols
The latest implementation of this template leaves trailing pipe symbols if a parameter is left empty. For example:



This used not to be the case. I'm having optional parameters (depending on where the page is transcluded) which are therefore sometimes left empty, so ideally the trailing pipe would not be printed in that case. Could someone perhaps improve this ( or maybe)? Thanks. Thayts  •••  22:28, 21 December 2020 (UTC)
 * Just a note that I've moved this here, since all of the separate templates now use the same module. Definitely something that can be looked at. Primefac (talk) 02:16, 22 December 2020 (UTC)


 * I think this can be fixed by changing the getArgs (Module:Arguments) invocation. Just set removeblanks=false.
 * Artoria2e5 🌉 07:18, 22 December 2020 (UTC)
 * The only issue is that the template documentation (and past usage) indicates that blank parameters will be honored. We don't want to say something like ...can be used as and have it show up as, because those two inputs would give completely different outputs. Primefac (talk) 14:04, 22 December 2020 (UTC)
 * At least trailing blank parameters were not shown, also not in past usage. I noticed something changed to this template when I saw the trailing pipes. Thayts   •••  19:04, 22 December 2020 (UTC)
 * That's fair. Will have to think about the best way to deal with that. Primefac (talk) 13:13, 23 December 2020 (UTC)
 * It works if you replace lines 99-108 in Module:Template link general with:

local textPart = "" local textPartBuffer = "" local i = 2 while args[i] do		local val = args[i] if val ~= nil then val = mw.text.unstripNoWiki(val) else break end textPartBuffer = textPartBuffer .. '&amp;#124;' if val ~= "" then if _ne(args.nowiki) then val = nw(val) end if italic then val = ' ' .. val .. ' ' end textPart = textPart .. textPartBuffer .. val textPartBuffer = "" end i = i+1 end
 * Thayts  •••  10:50, 13 February 2021 (UTC)
 * Looks good to me, thanks and ✅. Primefac (talk) 14:17, 13 February 2021 (UTC)
 * Thanks ! I also just realised that there is a redundant null check on line 104, since that check is already done in the while-statement. So you could simply replace it with  .  Thayts   •••  11:54, 14 February 2021 (UTC)
 * Actually, after stripping the nowiki tags you could end up with an empty value. So better to replace lines 103-104 with  (also trimming away spaces that might be in between the nowiki tags).  Thayts   •••  12:20, 14 February 2021 (UTC)
 * Sandbox it, test it, if it works I can implement. Primefac (talk) 14:06, 14 February 2021 (UTC)
 * Done, works fine. Thayts   •••  18:48, 14 February 2021 (UTC)
 * Thanks, implemented. Primefac (talk) 22:02, 20 February 2021 (UTC)

Broken with Template:Draft categories
does not work as expected. The "categories" are rendered as actual, active categories. For an example, see the bottom section of this revision. davidwr/ (talk)/(contribs) 🎄  14:18, 21 December 2020 (UTC)
 * Just a note that I've moved this here since all of the templates use the same module now. Primefac (talk) 02:25, 22 December 2020 (UTC)

Need a simple summary in the introduction
As someone who has dealt with simple html and other coding to only a limited extent over the years, I'm none the much wiser after reading the article. It would be great if some guidance on, for example, situations in which tlx is used, what it does in a nutahell, could be added. Clearly I'm not the one to do it, though. Sorry... Cheers, Simon – SCHolar44 🇦🇺 💬 at 03:56, 26 January 2021 (UTC)
 * I chucked some examples into the first table. Does that help? Primefac (talk) 16:40, 26 January 2021 (UTC)
 * Thank you for looking at this and for creating the examples, Primefac. But -- and I don't mean this in any way discourteously -- it doesn't help as far as the problem (as I see it) is concerned. What I think is needed is something that a knowledgeable person would say to an ignorant person who had looked over his/her shoulder at the computer screen and asked "What's that?"


 * At present there is: "This template, often abbreviated as, is used to provide stylized links to templates without expanding the template itself." Essentially I don't know what "stylized links" are, or what "without expanding the template itself" means (there you are, that's my qualification for ignorance!).


 * My job often involves demystifying complex scientific papers for non-scientific readers (often the officials/ministers who provide the funding, so it's important to have it as clear as possible). I find the "looking over shoulder" analogy useful because the specialist's response is usually simple and spot on... Cheers, Simon – SCHolar44 🇦🇺 💬 at 00:54, 27 January 2021 (UTC)
 * Never liked the "expanding" wording myself, to be honest... used to provide stylized formatting to template displays without actually using the template itself sound better? Primefac (talk) 01:17, 27 January 2021 (UTC)
 * Many thanks, Primefac -- that goes a good part of the way! Once I understand it better, I'll see if I can "apply my ignorance" to go further still. Thanks again for your help. Best wishes, Simon – SCHolar44 🇦🇺 💬 at 02:26, 27 January 2021 (UTC)

Template-protected edit request on 20 February 2021
Add just before the #invoke so the template can be substituted cleanly. JsfasdF252 (talk) 17:54, 20 February 2021 (UTC)
 * ✅ * Pppery * it has begun... 18:40, 20 February 2021 (UTC)
 * Why don't more module-based templates use safesubst? JsfasdF252 (talk) 20:20, 20 February 2021 (UTC)

Subst link
It would be helpful if tls outputs something like this: { {subst:tls}} rather than this: { {subst:tls}}. Can the module be modified to handle this? JsfasdF252 (talk) 01:32, 24 February 2021 (UTC)
 * Looks like this was changed when we switched to the module wrapper last year. Pinging the main editors (Artoria2e5 or Primefac); was this an intentional change? —&#8239; The Earwig (talk) 22:21, 26 February 2021 (UTC)
 * Sorry, been meaning to reply to this but more pressing things keep popping up. tls and gave the two versions demonstrated above, and so when everything was folded into tlg the tls formatting kinda got lost. If there's a desire to have it go the other way I'm sure that can be implemented. Primefac (talk) 22:31, 26 February 2021 (UTC)

Template link expanded with no parameters?
A recent edit to Help:Displaying a formula changed tl to tlx with no parameters. Is that a legitimate use of tlx? IAC,the introduction to Template:Template link expanded should provide guidance as to whether it is appropriate to use tlx with no parameters. Shmuel (Seymour J.) Metz Username:Chatul (talk) 14:06, 8 March 2021 (UTC)
 * Why wouldn't it be? The only difference between tl and tlx is whether it has code or not, i.e. tl vs, which is entirely a stylistic choice. Primefac (talk) 14:16, 8 March 2021 (UTC)
 * Why have distinct tl and tlx templates if they are essentially the same? Why did you change the invocations if they are the same? And why shouldn't the documentaion make it clear what the intended usage is? Shmuel (Seymour J.) Metz Username:Chatul (talk) 14:23, 8 March 2021 (UTC)
 * First, they are essentially the same, but tlx avoids the need to use yes when you want to make the text appear in a  block. Second, I didn't change anything (I am not Somerandomuser). Third, there isn't a clearly-defined use case on the documentation because there aren't clearly-defined times when specific templates should be used. Personally, I find using t or similar much faster if I'm just putting the template in conversation like this one, and if I want to emphasize something I'll chuck it into tlx so that it "pops" (just like I did with the code param above).
 * Generally speaking, though, changing the overall style of a Wikipedia- or Help-space page probably shouldn't be done en-masse without discussion, but since they are not user-facing (editors are the primary ones who will be reading such pages) at the end of the day it really doesn't matter all that much. Primefac (talk) 14:31, 8 March 2021 (UTC)
 * I was trying to clean things up and increase article readability by creating a distinction between the code and the surrounding text. I saw that the page used multiple styles and I tried consolidating them. Somerandomuser (talk) 02:53, 12 March 2021 (UTC)
 * I've reverted many of the tlx templates back to tl to adhere to a general style. Somerandomuser (talk) 02:33, 13 March 2021 (UTC)

Nowiki stopped working
For some reason, nowiki quit working inside parameter input with this and related templates for a while (I think I encountered this about 24 to 36 hours ago):

produced output that looked like:

instead of:

My immediate suspicion is that it had something to do with the TfD-related tagging (and dispute about that) around that time period, under discussion here and here. Whatever caused it should be identified, and we should see if there's a way to prevent that in the future, since it (temporarily) corrupted a whole lot of template documentation into gibberish (and worse, like completely incorrect descriptions of parameter usage and behavior). — SMcCandlish ☏ ¢ 😼  23:21, 23 March 2021 (UTC)
 * I see zero reason why adding the TfD template would cause the  to stop working, except for maybe it could be a parser issue with the extra code added on causing an overload, but that usually affects transclusions not tags. Plus, we've had "well-used" templates get tagged before and it has not adversely affected them. Server-side glitch? Primefac (talk) 23:32, 23 March 2021 (UTC)
 * I can't think of any possible explanation for it stopping working recently. From my reading of the code, it appears to have been broken since November 2020, when Module:Template link general was deployed. That module has called mw.text.unstripNoWiki on each template parameter, and has since Special:Diff/952179764 for reasons I don't understand. You can work around this with  (producing, but I agree that how to format parameters should be none of this template's business. * Pppery * it has begun...  03:09, 24 March 2021 (UTC)
 * I've added some code to Module:Template link general/sandbox that should fix this issue. Although many of testcases are yellow, the differences are non-visual, except for the corner case that parameters containing empty nowiki tags at the end no longer ignored, which nothing should care about (and I'd argue that the new behavior is more correct anyway). * Pppery * it has begun... 03:45, 24 March 2021 (UTC)
 * Since we're referring to this family of templates (neither Template:Template link nor Template:Tlu use the tlg module) I've moved the discussion here. Primefac (talk) 10:29, 24 March 2021 (UTC)

Please implement the above sandboxed code to address this bug. * Pppery * it has begun... 20:32, 24 April 2021 (UTC)
 * Yes check.svg Done Primefac (talk) 10:37, 25 April 2021 (UTC)

Showing the result of the code
I've modified the /sandbox to enable the module to additionally show the output of the code when using _show_result.

I've tested the above scenarios which work. Gonnym (talk) 14:42, 15 January 2022 (UTC)
 * Would it be possible to use → since it's an actual arrow? That being said, I like the idea; will save a lot of excess typing in template documentation. Primefac (talk) 14:47, 15 January 2022 (UTC)
 * Yeah, the arrow was just a fast example. Anything else if fine by me. Gonnym (talk) 15:06, 15 January 2022 (UTC)
 * I've also modified the parameter to an underscore parameter _show_result instead of show_result for the very rare case of the template itself having a parameter with that name. Gonnym (talk) 15:09, 15 January 2022 (UTC)
 * Good call. I'd wait a bit for other opinions but I suspect no one will care and it can be implemented (since it's an "additional functionality" type change). Primefac (talk) 15:42, 15 January 2022 (UTC)
 * Can this be implemented? Gonnym (talk) 14:21, 28 January 2022 (UTC)
 * Fine by me! Primefac (talk) 15:01, 28 January 2022 (UTC)

Per the above discussion, please copy the version in the sandbox. Gonnym (talk) 17:54, 28 January 2022 (UTC)
 * ✅ Apologies for making you take the extra step for this, I completely forgot this was fully protected. Primefac (talk) 21:30, 28 January 2022 (UTC)
 * Can you please sync again? I had a small error where I started the unnamed table at 2 instead of at 1. Gonnym (talk) 22:01, 28 January 2022 (UTC)
 * ✅. Primefac (talk) 09:02, 29 January 2022 (UTC)

, just came across a case where if you put a named parameter in the middle of unnamed parameters, it messes with the order of the unnamed parameters (note the older version has three "Charles Darwin" links instead of language links in the #Piping links section). Is this an edge case or something that should probably be looked at? Primefac (talk) 10:34, 2 March 2022 (UTC)
 * I've actually had some fixes in the /sandbox for cases like this and it seems to work with this example:
 * I've also added an option for _expand which adds an expand template link. See examples:
 * Try it out and let me know if there are issues. --Gonnym (talk) 14:53, 2 March 2022 (UTC)
 * @Primefac just incase you missed this. Gonnym (talk) 13:28, 7 March 2022 (UTC)
 * I didn't miss it, just been dealing with bigger spoons recently. Primefac (talk) 15:30, 7 March 2022 (UTC)
 * Try it out and let me know if there are issues. --Gonnym (talk) 14:53, 2 March 2022 (UTC)
 * @Primefac just incase you missed this. Gonnym (talk) 13:28, 7 March 2022 (UTC)
 * I didn't miss it, just been dealing with bigger spoons recently. Primefac (talk) 15:30, 7 March 2022 (UTC)
 * Try it out and let me know if there are issues. --Gonnym (talk) 14:53, 2 March 2022 (UTC)
 * @Primefac just incase you missed this. Gonnym (talk) 13:28, 7 March 2022 (UTC)
 * I didn't miss it, just been dealing with bigger spoons recently. Primefac (talk) 15:30, 7 March 2022 (UTC)

kbd
Both plaincode and kbd produce the same result visually but kbd is not very good semantically. Shouldn't it be discouraged from using? Tran Xuan Hoa (talk) 12:00, 21 April 2023 (UTC)
 * Visually similar with completely different backend code, which is why they're both there. I'm not sure what you mean by "not very good semantically" since  is the name of the tag itself. Primefac (talk) 13:56, 21 April 2023 (UTC)
 * The kbd HTML element "denotes textual user input from a keyboard or any other text entry device". I wasn't sure if wrapping whole template code, e.g. inside  is correct usage. Perhaps it is acceptable to count template code as keyboard input(?) Tran Xuan Hoa (talk) 16:07, 21 April 2023 (UTC)
 * It's not wrong, if that's what you're wondering; it wouldn't be in the template if it were. Primefac (talk) 17:25, 21 April 2023 (UTC)

Template-protected edit request on 17 July 2023
Hi. This template makes infinitely large columns, and this is visible especially in tables. Would it be possible to add the  tag before each   (i.e.  )?

Currently tlnp uses, and you can compare the two behaviours when the two templates are transcluded in a confined space.

tlp:

tlnp:

Grufo (talk) 15:11, 17 July 2023 (UTC)
 * We'll need consensus for this change. Please link to a page where this is a problem. The template (Template link with parameters) specifically includes yes in its code, so it seems counterproductive (or possibly not functional) to override that option by inserting wbr tags. I don't know why yes is in there, but you might look in the discussion archives or the edit history for the reason. – Jonesey95 (talk) 22:03, 17 July 2023 (UTC)
 * What you say brings the suspect that there might actually be a bug and not just a design problem: I am not asking to override yes, I am asking to make the template wrappable when people do not specify yes. Right now it seems that even if I don't specify yes the template behaves as if I did (look at my example above). Please link to a page where this is a problem: Just to mention one case, in the documentation of this very template before I  by removing the tlx template and I replaced it with tji (compare some of the tables in the two versions). --Grufo (talk) 23:04, 17 July 2023 (UTC)
 * Can you please be more specific about which line of the table was not rendering well? You changed many things in that edit, and I'm not seeing a difference right away. – Jonesey95 (talk) 00:52, 18 July 2023 (UTC)
 * BTW, this template appears to have had nowrap set since this change in 2009. I don't see anyone asking about it in the archive of either talk page, but I may have missed something. – Jonesey95 (talk) 00:58, 18 July 2023 (UTC)
 * Yours is a strange approach. I come here reporting a bug and an example that shows it. A good programmer would immediately look for what is wrong, not argue about whether what is wrong is truly wrong. But yet, I get asked to bring more proof. I do. And then I get answered that everyone has been being OK with a broken template since 2009. Well… What can I say? Can you please be more specific about which line of the table was not rendering well?: Sure. From line 69 to line 106 in both versions (both and  my edits). But this is just the tip of the iceberg and I have encountered this problem several times; the very reason why both templates tji and tlnp do have the   tag in their code is exactly to avoid the weird behavior of tlx – the same reason that ultimately brought me here. --Grufo (talk) 01:20, 18 July 2023 (UTC)
 * You are welcome to insult me if you want, but it makes it less likely that I, or another experienced template editor, will be willing to help you. Good luck. – Jonesey95 (talk) 03:41, 18 July 2023 (UTC)

Mind handing a shortcut to Template:Template link with sorted parameters?
Template link with subst has quite a few shortcuts: tls, tlsp, tlps; would you mind leaving one for Template link with sorted parameters? I see that the tlps shortcut is not advertised and is currently used by only a hundred pages. Maybe that could be the one? Or if you have another name to suggest, I would be more than happy avoiding to edit 100 pages. --Grufo (talk) 18:41, 17 July 2023 (UTC)
 * I am genuinely curious - when would anyone ever use that template? If they want things in the "right" order they'll just type them in that order. Primefac (talk) 07:37, 18 July 2023 (UTC)
 * The main point of that template is that you don't have to escape the equals sign. That means that you can just write
 * and you will get
 * But I could not present it only as “the template that lets you write equals signs freely”, because something else happens too: the order of named parameters is always lost during a call, and if I advertised the template as “the template that lets you write equals signs freely” you would think that that is the only thing that the template does, and your order is preserved; but that would be false. And so, in order to let you write the equals sign freely you must give up your custom sorting. Because rearranging the order sounds like the major feature to me compared to “write the equals sign freely”, the way that template is presented is Template link with sorted parameters.
 * And here we go to the second question: If they want things in the "right" order they'll just type them in that order. In that case (i.e. if they themselves use the right order), they should definitely use the tlap template, because then they won't have to escape the equals sign. Compare writing
 * with writing
 * The only case in which tlap becomes useless is when users for whatever reason do not want an alphabetical order. But even in that case, tlap can be used with escaped equals and it will behave like tlp.
 * P.S. By the way, as you might have guessed, I have found the tlap shortcut for this template (where the “a” stands for “alphabetically”). --Grufo (talk) 20:10, 18 July 2023 (UTC)
 * with writing
 * The only case in which tlap becomes useless is when users for whatever reason do not want an alphabetical order. But even in that case, tlap can be used with escaped equals and it will behave like tlp.
 * P.S. By the way, as you might have guessed, I have found the tlap shortcut for this template (where the “a” stands for “alphabetically”). --Grufo (talk) 20:10, 18 July 2023 (UTC)
 * P.S. By the way, as you might have guessed, I have found the tlap shortcut for this template (where the “a” stands for “alphabetically”). --Grufo (talk) 20:10, 18 July 2023 (UTC)

Why ignore empty parameters
Template:Template link general/doc documents that this template and its derivatives ignore empty parameters. Why is this? I was brought here because I fixed some documentation written by another user which presented incorrect information because the author did not anticipate this behavior. I'm trying to understand if this is a bug or a feature. Daask (talk) 19:08, 13 October 2023 (UTC)
 * It's a bug that I feel like was solved at one point but seems not to be. Primefac (talk) 19:32, 13 October 2023 (UTC)
 * This also leads to an incorrect example at Template:Highlight/doc. LittlePuppers (talk) 03:05, 7 November 2023 (UTC)

A better way to handle named parameters?
Had a thought about directly supporting named parameters instead of requiring the workaround of. What would it look like if we supported parameters  that would display as   where the named parameters have an explicit place in the order of the parameters and the unnamed parameters fill in any holes. You could even contrast upper and lower case for named parameter explanations, so  would show up as. Any thoughts or concerns? VanIsaac, GHTVcont WpWS 18:35, 6 December 2023 (UTC)
 * I am unable to parse your examples above. There are many typos. Can you please proofread and correct your examples? – Jonesey95 (talk) 16:37, 7 December 2023 (UTC)
 * Same; I don't really understand what's being proposed. Primefac (talk) 19:22, 7 December 2023 (UTC)
 * From what I can tell, the desire is to be able to do  to get display that looks like  . But this is kind of pointless when you can already do:
 * for.
 * for identical output
 * for the same result
 * — SMcCandlish ☏ ¢ 😼  00:18, 25 December 2023 (UTC)

Redundancy of tlc and tlx
The and  templates' features seem to have become almost entirely redundant with each other over time, and these two templates should probably be merged. — SMcCandlish ☏ ¢ 😼  23:51, 24 December 2023 (UTC)
 * They always have been redundant - the only difference between them is one is linked vs unlinked . Primefac (talk) 00:32, 25 December 2023 (UTC)