Template talk:Template link general

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:Tn)
WikiProject iconTemplates
WikiProject iconThis template (like all templates) is within the scope of WikiProject Templates, a group dedicated to improving the maintenance of Wikipedia's templates. This particular template is especially important to the project because it is used in the maintenance of other templates. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.

Trailing pipe symbols[edit]

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

{{tnull|wd|label|}}{{wd|label|}}

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 (Artoria2e5 or Primefac maybe)? Thanks. Thayts ••• 22:28, 21 December 2020 (UTC)[reply]

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)[reply]
I think this can be fixed by changing the getArgs (Module:Arguments) invocation. Just set removeblanks=false.
Artoria2e5 🌉 07:18, 22 December 2020 (UTC)[reply]
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 {{fnh|surname|pen name}} and have it show up as {{fnh|surname|pen name}}, because those two inputs would give completely different outputs. Primefac (talk) 14:04, 22 December 2020 (UTC)[reply]
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)[reply]
That's fair. Will have to think about the best way to deal with that. Primefac (talk) 13:13, 23 December 2020 (UTC)[reply]
@Primefac: 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 .. '|'
		if val ~= "" then
			if _ne(args.nowiki) then val = nw(val) end
			if italic then val = '<span style="font-style:italic;">' .. val .. '</span>' end
			textPart = textPart .. textPartBuffer .. val
			textPartBuffer = ""
		end
		i = i+1
	end
Thayts ••• 10:50, 13 February 2021 (UTC)[reply]
Looks good to me, thanks and  Done. Primefac (talk) 14:17, 13 February 2021 (UTC)[reply]
Thanks Primefac! 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 val = mw.text.unstripNoWiki(val) and even put it in the if-statement below that. Thayts ••• 11:54, 14 February 2021 (UTC)[reply]
Actually, after stripping the nowiki tags you could end up with an empty value. So better to replace lines 103-104 with local val = mw.text.trim(mw.text.unstripNoWiki(args[i])) (also trimming away spaces that might be in between the nowiki tags). Thayts ••• 12:20, 14 February 2021 (UTC)[reply]
Sandbox it, test it, if it works I can implement. Primefac (talk) 14:06, 14 February 2021 (UTC)[reply]
@Primefac: Done, works fine. Thayts ••• 18:48, 14 February 2021 (UTC)[reply]
Thanks, implemented. Primefac (talk) 22:02, 20 February 2021 (UTC)[reply]

{{tlx|draft categories|<nowiki>1=[[Category:first category]][[Category:second category]]</nowiki>}}

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)[reply]

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)[reply]

Need a simple summary in the introduction[edit]

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)[reply]

I chucked some examples into the first table. Does that help? Primefac (talk) 16:40, 26 January 2021 (UTC)[reply]
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 {{tlg}}, 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)[reply]
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)[reply]
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)[reply]

Template-protected edit request on 20 February 2021[edit]

Add {{{|safesubst:}}} just before the #invoke so the template can be substituted cleanly. JsfasdF252 (talk) 17:54, 20 February 2021 (UTC)[reply]

 Done * Pppery * it has begun... 18:40, 20 February 2021 (UTC)[reply]
Why don't more module-based templates use safesubst? JsfasdF252 (talk) 20:20, 20 February 2021 (UTC)[reply]

Subst link[edit]

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)[reply]

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? — The Earwig (talk) 22:21, 26 February 2021 (UTC)[reply]
Sorry, been meaning to reply to this but more pressing things keep popping up. {{tls}} and {{tlg|subst=yes}} 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)[reply]

Template link expanded with no parameters?[edit]

@Somerandomuser: 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)[reply]

Why wouldn't it be? The only difference between {{tl}} and {{tlx}} is whether it has code or not, i.e. {{tl}} vs {{tlx}}, which is entirely a stylistic choice. Primefac (talk) 14:16, 8 March 2021 (UTC)[reply]
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)[reply]
First, they are essentially the same, but {{tlx}} avoids the need to use |code=yes when you want to make the text appear in a <code>...</code> 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)[reply]
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)[reply]
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)[reply]

Nowiki stopped working[edit]

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):

{{tlx|foo|bar|baz{{=}}<nowiki>[[Quux]]</nowiki>}}

produced output that looked like:

{{foo|bar|baz=Quux}}

instead of:

{{foo|bar|baz=[[Quux]]}}

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)[reply]

I see zero reason why adding the TfD template would cause the [[Template:{{{1}}}|{{{1}}}]] 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)[reply]
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 {{tlx|foo|bar|baz=[[quux]]|nowiki}yes}} (producing {{foo|bar|baz=[[quux]]}}, 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)[reply]
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)[reply]
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)[reply]

Please implement the above sandboxed code to address this bug. * Pppery * it has begun... 20:32, 24 April 2021 (UTC)[reply]

 Done Primefac (talk) 10:37, 25 April 2021 (UTC)[reply]

Showing the result of the code[edit]

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

  • {{Min}}
  • {{Min|-7}} → -7
  • {{Min|7|-5}} → -5
  • {{Min|1=-7}} → -7
  • {{Min|1=7|2=-5}} → -5

I've tested the above scenarios which work. Gonnym (talk) 14:42, 15 January 2022 (UTC)[reply]

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)[reply]
Yeah, the arrow was just a fast example. Anything else if fine by me. Gonnym (talk) 15:06, 15 January 2022 (UTC)[reply]
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)[reply]
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)[reply]
Can this be implemented? Gonnym (talk) 14:21, 28 January 2022 (UTC)[reply]
Fine by me! Primefac (talk) 15:01, 28 January 2022 (UTC)[reply]

Per the above discussion, please copy the version in the sandbox. Gonnym (talk) 17:54, 28 January 2022 (UTC)[reply]

 Done 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)[reply]
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)[reply]
 Done. Primefac (talk) 09:02, 29 January 2022 (UTC)[reply]

Gonnym, 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)[reply]

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)[reply]
@Primefac just incase you missed this. Gonnym (talk) 13:28, 7 March 2022 (UTC)[reply]
I didn't miss it, just been dealing with bigger spoons recently. Primefac (talk) 15:30, 7 March 2022 (UTC)[reply]

kbd[edit]

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)[reply]

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 kbd is the name of the tag itself. Primefac (talk) 13:56, 21 April 2023 (UTC)[reply]
The kbd HTML element "denotes textual user input from a keyboard or any other text entry device"[6]. I wasn't sure if wrapping whole template code, e.g. {{Example|param1=val1|param2=val2}} inside <kbd>...</kbd> is correct usage. Perhaps it is acceptable to count template code as keyboard input(?) Tran Xuan Hoa (talk) 16:07, 21 April 2023 (UTC)[reply]
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)[reply]

Template-protected edit request on 17 July 2023[edit]

Hi. This template makes infinitely large columns, and this is visible especially in tables. Would it be possible to add the <wbr /> tag before each |argument (i.e. <wbr />|argument)?

Currently {{tlnp}} uses <wbr />, and you can compare the two behaviours when the two templates are transcluded in a confined space.

{{tlp}}:

{{See also|Article1|Article2|Article3|label 1=A|label 2=B|label 3=C}}

{{tlnp}}:

{{tlnp|See also|Article1|Article2|Article3|label 1=A|label 2=B|label 3=C}}

Grufo (talk) 15:11, 17 July 2023 (UTC)[reply]

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 |nowrap=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 |nowrap=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)[reply]
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 |nowrap=yes, I am asking to make the template wrappable when people do not specify |nowrap=yes. Right now it seems that even if I don't specify |nowrap=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, there was a problem in the documentation of this very template before I fixed it 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)[reply]
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)[reply]
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)[reply]
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 before and after 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 <wbr /> 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)[reply]
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)[reply]

{{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)[reply]

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)[reply]
The main point of that template is that you don't have to escape the equals sign. That means that you can just write
{{tlap|See also|Article1|Article2|Article3|label 1=A|label 2=B|label 3=C}}
and you will get
{{tlap|See also|Article1|Article2|Article3|label 1=A|label 2=B|label 3=C}}
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
{{tlap|Example|christmas=tree|foo=bar|hello=world}}
with writing
{{tlp|Example|christmas{{=}}tree|foo{{=}}bar|hello{{=}}world}}
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)[reply]

Why ignore empty parameters[edit]

Template:Template link general/doc#Examples 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)[reply]

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)[reply]
This also leads to an incorrect example at Template:Highlight/doc. LittlePuppers (talk) 03:05, 7 November 2023 (UTC)[reply]

A better way to handle named parameters?[edit]

Had a thought about directly supporting named parameters instead of requiring the workaround of named{{=}}. What would it look like if we supported parameters a=named1, b=named2, c=named3... z=named26 that would display as {{templatename|named1=|unnamed1|unamed2|named4=|unamed3}} 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 {{tlp|templatename|a=named1|A=explanation1}} would show up as {{templatename|named1=explanation1}}. Any thoughts or concerns? VanIsaac, GHTV contWpWS 18:35, 6 December 2023 (UTC)[reply]

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)[reply]
Same; I don't really understand what's being proposed. Primefac (talk) 19:22, 7 December 2023 (UTC)[reply]
From what I can tell, the desire is to be able to do {{tlx|templatename|a=weasel=yes|b=snorkel=|c=3=23%}} to get display that looks like {{templatename|weasel=yes|snorkel=|3=23%}}. But this is kind of pointless when you can already do:
  • {{tlx|templatename|2=weasel=yes|3=snorkel=|4=3=23%}} for {{templatename|weasel=yes|snorkel=|3=23%}}.
  • {{tlx|templatename|weasel{{=}}yes|snorkel{{=}}|3{{=}}23%}} for identical {{templatename|weasel=yes|snorkel=|3=23%}} output
  • {{tlx|templatename|<nowiki>weasel=yes|snorkel=|3=23%</nowiki>}} for the same result {{templatename|weasel=yes|snorkel=|3=23%}}
 — SMcCandlish ¢ 😼  00:18, 25 December 2023 (UTC)[reply]

Redundancy of tlc and tlx[edit]

The {{tlc}} and {{tlx}} 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)[reply]

They always have been redundant - the only difference between them is one is linked {{tlx}} vs unlinked {{tlc}}. Primefac (talk) 00:32, 25 December 2023 (UTC)[reply]