Template talk:Template link general
| To help centralise discussions and keep related topics together, the talk pages of all templates directly invoking Module:Template link general redirect here. |
| Text and/or other creative content from this version of Template:Tlg was copied or moved into incubator:Template:Wp/nod/tlg with this edit. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted so long as the latter page exists. |
| WikiProject Templates | |||||||
|
|||||||
|
|
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)
- 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 {{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)- 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)
- @Primefac: It works if you replace lines 99-108 in Module:Template link general with:
- That's fair. Will have to think about the best way to deal with that. Primefac (talk) 13:13, 23 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)
- 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
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)
- Looks good to me, thanks and
Done. Primefac (talk) 14:17, 13 February 2021 (UTC)
- 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) - 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)
- 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
- Looks good to me, thanks and
- Thayts ••• 10:50, 13 February 2021 (UTC)
Broken with Template:Draft categories[edit]
{{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)
- 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[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)
- 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 {{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)
- 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)
- Never liked the "expanding" wording myself, to be honest...
- 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)
Template-protected edit request on 20 February 2021[edit]
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Add {{{|safesubst:}}} just before the #invoke so the template can be substituted cleanly. JsfasdF252 (talk) 17:54, 20 February 2021 (UTC)
Done * 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[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)
- 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)
- 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)
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)
- 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)- 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
|code=yeswhen 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)
- First, they are essentially the same, but {{tlx}} avoids the need to use
- 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)
- 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[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:
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)
- 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) - 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) - 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)
This edit request to Module:Template link general has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please implement the above sandboxed code to address this bug. * Pppery * it has begun... 20:32, 24 April 2021 (UTC)
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=.
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)
This edit request to Module:Template link general has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Per the above discussion, please copy the version in the sandbox. Gonnym (talk) 17:54, 28 January 2022 (UTC)
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)
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)
- I've actually had some fixes in the /sandbox for cases like this and it seems to work with this example:
{{ill|Charles Darwin (botanist)|text=Charles Darwin|fr|Charles Darwin|de|Charles Darwin|es|Charles Darwin}}→ Charles Darwin (botanist)
- 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)