ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.
Template talk:S: Difference between revisions
Jump to navigation
Jump to search
This template should succeed Template:Sl. |
Reply |
||
Line 1: | Line 1: | ||
[[Template:Sl]] exists, but it can also be used to generate a section link, followed by a right arrow, followed by a flag link. For example, <code><nowiki>{{sl|General|BarrelDebris}}</nowiki></code> yields {{sl|General|BarrelDebris}}. Perhaps the functionality of [[Template:F]] could be added to this template or some other solution for maintaining formatting devised. | [[Template:Sl]] exists, but it can also be used to generate a section link, followed by a right arrow, followed by a flag link. For example, <code><nowiki>{{sl|General|BarrelDebris}}</nowiki></code> yields {{sl|General|BarrelDebris}}. Perhaps the functionality of [[Template:F]] could be added to this template or some other solution for maintaining formatting devised. | ||
--this unsigned comment was made by [[User:Vinifera7|Vinifera7]] | |||
:Yeah, I noticed Template:Sl existed after I created S (and I also noticed I was the one who originally wrote Sl, which makes it even sillier that I missed it), and I left it alive exactly ''because'' of that special case. | |||
:Any template you include in a page is expanded and evaluated every time it gets loaded, so the longer a template, the bigger the expansion and the more expensive the processing. So, while I, on principle, 100% agree that S should supersede Sl for simple section linking, I decided to leave Sl standing for those who want to use the arrow special case. That way, if you just want to do a quick link, you can go for S with minimal overhead, and if you want to create a more detailed link to a sub-flag, you can use Sl. | |||
:In addition, you have to consider the number of cases you'd have to catch: | |||
<pre> | |||
{{s|General}} | |||
{{s|General|link}} | |||
{{s|General|BarrelDebris}} | |||
{{s|General|BarrelDebris|link}} | |||
{{s|General|BarrelDebris|link|link}} | |||
</pre> | |||
:or, alternatively, | |||
<pre> | |||
{{s|General}} | |||
{{s|General|link}} | |||
{{s|General|nolink|BarrelDebris}} | |||
{{s|General|link|BarrelDebris}} | |||
{{s|General|link|BarrelDebris|link}} | |||
</pre> | |||
:Either way, you'd need a whole bunch of extra checks to figure out what exactly the user wants, or you'd have to name the variables, which goes contrary to the concept of it being a "quick" template. | |||
:Adding to the whole problem is also the little-known fact that you can't actually have infinite templates in a page. If you look at the source of a given MediaWiki page, you'll find a comment like this one: | |||
<pre><!-- | |||
NewPP limit report | |||
Preprocessor node count: 40/1000000 | |||
Post-expand include size: 192/2097152 bytes | |||
Template argument size: 42/2097152 bytes | |||
Expensive parser function count: 0/100 | |||
--></pre> | |||
:I've been an editor and template maintainer on a wiki where we had a tiny template that selected initials for certain people. You would call it like <nowiki>{{initial|person name}}</nowiki> and an ever-growing switch in the template would select the correct, formatted initials for that person. | |||
:The result? On a certain page, that template was included almost 300 times, leading to 300 times the entire switch being included into the page. After the switch had reached a certain critical mass, the Post-expand include size exceeded the cut-off value, and templates after a certain point on the page simply weren't processed anymore. The calls just appeared in text, as if they were nowiki'd. | |||
:Of course that's a drastic scenario, and it's unlikely that'll happen with this particular template, but it helps to remember what actually happens in the background with templates, and to keep that in mind when designing them - especially when adding more code for special cases. | |||
:So, as said: On principle, I agree they could be merged, I agree they overlap to a large part, but given that section link + sub-flag link is somewhat different than just section link, and given that the extra processing would add a considerable amount of new code, I'd like to keep this one as a pure section link template, leaving the other one for the special case. I will, however, now that I'm not he only one who noticed anymore >_>, add a note to Template:Sl pointing out S for the simpler case. :) | |||
:Thanks for keeping your eyes open :) | |||
::~ [[User:Renegade|Renegade]] ([[ModEnc:Administrators|SysOp]]) 21:15, 28 November 2009 (UTC) |
Latest revision as of 21:15, 28 November 2009
Template:Sl exists, but it can also be used to generate a section link, followed by a right arrow, followed by a flag link. For example, {{sl|General|BarrelDebris}}
yields [General]→BarrelDebris=. Perhaps the functionality of Template:F could be added to this template or some other solution for maintaining formatting devised.
--this unsigned comment was made by Vinifera7
- Yeah, I noticed Template:Sl existed after I created S (and I also noticed I was the one who originally wrote Sl, which makes it even sillier that I missed it), and I left it alive exactly because of that special case.
- Any template you include in a page is expanded and evaluated every time it gets loaded, so the longer a template, the bigger the expansion and the more expensive the processing. So, while I, on principle, 100% agree that S should supersede Sl for simple section linking, I decided to leave Sl standing for those who want to use the arrow special case. That way, if you just want to do a quick link, you can go for S with minimal overhead, and if you want to create a more detailed link to a sub-flag, you can use Sl.
- In addition, you have to consider the number of cases you'd have to catch:
{{s|General}} {{s|General|link}} {{s|General|BarrelDebris}} {{s|General|BarrelDebris|link}} {{s|General|BarrelDebris|link|link}}
- or, alternatively,
{{s|General}} {{s|General|link}} {{s|General|nolink|BarrelDebris}} {{s|General|link|BarrelDebris}} {{s|General|link|BarrelDebris|link}}
- Either way, you'd need a whole bunch of extra checks to figure out what exactly the user wants, or you'd have to name the variables, which goes contrary to the concept of it being a "quick" template.
- Adding to the whole problem is also the little-known fact that you can't actually have infinite templates in a page. If you look at the source of a given MediaWiki page, you'll find a comment like this one:
<!-- NewPP limit report Preprocessor node count: 40/1000000 Post-expand include size: 192/2097152 bytes Template argument size: 42/2097152 bytes Expensive parser function count: 0/100 -->
- I've been an editor and template maintainer on a wiki where we had a tiny template that selected initials for certain people. You would call it like {{initial|person name}} and an ever-growing switch in the template would select the correct, formatted initials for that person.
- The result? On a certain page, that template was included almost 300 times, leading to 300 times the entire switch being included into the page. After the switch had reached a certain critical mass, the Post-expand include size exceeded the cut-off value, and templates after a certain point on the page simply weren't processed anymore. The calls just appeared in text, as if they were nowiki'd.
- Of course that's a drastic scenario, and it's unlikely that'll happen with this particular template, but it helps to remember what actually happens in the background with templates, and to keep that in mind when designing them - especially when adding more code for special cases.
- So, as said: On principle, I agree they could be merged, I agree they overlap to a large part, but given that section link + sub-flag link is somewhat different than just section link, and given that the extra processing would add a considerable amount of new code, I'd like to keep this one as a pure section link template, leaving the other one for the special case. I will, however, now that I'm not he only one who noticed anymore >_>, add a note to Template:Sl pointing out S for the simpler case. :)