Template talk:S-rail

Proposed change
During a discussion at Wikipedia talk:WikiProject Trains the idea of allowing the "skinning" of s-rail arose. The proposed change allows the setting of the background and text colors via the  template, using the   and   parameters. You would still need to define the color for the actual line name link in Template:S-rail/lines. The code necessary is pasted below: !Previous station ! style="border: 0px #aaa none; "| ! style="border: 0px #aaa none; "| ! style="border: 0px #aaa none; "| !Next station While this does increase the size of the template from 259 bytes to 1,044 bytes, the template inclusion size only goes up about 3-5K even on high-use articles, which seems tolerable. Thoughts or objections? Mackensen (talk) 21:04, 22 July 2007 (UTC)

Proposed change
Whilst it is the lowest of all importances, could someone please change the wording in the headers from Previous/Next to Preceding/Following. It just makes more technical and geographical sense; and it prevents that crushing of text (that happens when the termini are bigger than the headers). Kevin Steinhardt (talk) 04:13, 18 November 2007 (UTC)
 * Done. Mackensen (talk) 04:30, 18 November 2007 (UTC)

colspan middle column
A minor suggestion to span the middle column by 3, instead of having 3 separate columns, unless they are serving any other specific purposes now? - oahiyeel talk 20:20, 21 November 2007 (UTC)
 * Doing so forces the fixed width for the color bars; otherwise they vary depending on the size of the template. Mackensen (talk) 20:42, 21 November 2007 (UTC)

Width required by macro
When used on pages with very little content other than the Info Box, the template does not render until the end of the Info Box, leaving a large amount of white space to the right. This does not appear to happen on the older(?) rail template. As examples, see Brigg railway station and Baldock railway station. Can this be fixed? Ajcoxuk (talk) 16:47, 17 February 2008 (UTC)
 * Already has been. When using or, use the   parameter. I've demonstrated at Baldock. Mackensen (talk) 17:09, 17 February 2008 (UTC)

remove leading and trailing spaces
suggestion to remove the non-breaking spaces  before and after the "preceding station" and "following station". They are causing slight misalignment with regards to being ed. Unless they are there for a reason? - oahiyeel talk 07:20, 2 April 2008 (UTC)
 * Looks like those got added in November and were cosmetic only, so it's probably safe. Do you have an example of a misalignment? Mackensen (talk) 10:43, 2 April 2008 (UTC)
 * ✅ Happy‑melon 14:30, 5 April 2008 (UTC)

Edit request
This template is currently a member of Category:Rail succession templates, but that category has been redirected to Category:Rail transport succession templates, so the link should be updated. --Russ (talk) 20:11, 9 July 2008 (UTC) ✅--Mackensen (talk) 22:33, 9 July 2008 (UTC)

Bold style is unnecessary
Could someone please remove the bold style from "Preceding station" and "Following station". It is not necessary, as wikitables apply bold automatically. Mitch Ames (talk) 10:56, 8 October 2013 (UTC)
 * ✅ -- Red rose64 (talk) 12:33, 8 October 2013 (UTC)

Template-protected edit request on 5 January 2017
can someone fix or revert the recent changes? they make no sense. for example, why would you still try to use after you know that it doesn't exist? before the change, Template:Cairo Metro style had links but no transclusions. Now it has transclusions, which means we are going to get a bunch of template clogging up Database reports/Transclusions of deleted templates. 98.230.196.215 (talk) 01:10, 5 January 2017 (UTC) to reply to me 14:59, 6 January 2017 (UTC) to reply to me 09:32, 8 January 2017 (UTC) to reply to me 11:49, 8 January 2017 (UTC)
 * Edit-undo.svg Undone: This request has been undone. As there seem to be good-faith concerns about these recent edits, and they have not been discussed, I have reverted them all and invite User:Jc86035 to get consensus &mdash; Martin (MSGJ · talk) 09:40, 5 January 2017 (UTC)
 * What we have here, when used with Cairo Metro, is  which since Template:Cairo Metro style doesn't exist, reduces to   and the first test is empty, so it emits nothing. Compare when used with e.g. BART:   which since Template:BART style does exist, reduces to   but  returns the empty string, so again we get   and the first test is again empty, so it again emits nothing. If we didn't test for existence, the BART one would still reduce cleanly, but the Cairo Metro one would put invalid declarations into the   attribute. -- Red rose64 &#x1f339; (talk) 09:52, 5 January 2017 (UTC)
 * Clearly that wasn't happening, given the template calls to Cairo Metro style. The "old"/current version seems to work fine, given that the second option for an #ifexist is the same as a "false" for #if (i.e. there is no reason to have an #if:#ifexist). Maybe I'm just reading the code wrong? Primefac (talk) 15:08, 5 January 2017 (UTC)
 * Likely the reason there was a transclusion was because I didn't enclose the two instances of  in #ifexist: (and went off to make a Lua module instead because I thought it would load marginally faster). I've tried fixing that in the sandbox; the main template still needs the header colour fix to match site CSS. Jc86035 (talk) Use &#123;&#123;re&#124;Jc86035&#125;&#125;
 * I've merged the sandbox into the main template. Jc86035 (talk) Use &#123;&#123;re&#124;Jc86035&#125;&#125;
 * Did you know that in a declaration like  one of the values is redundant? [//www.w3.org/TR/css-backgrounds-3/#valdef-line-style-none A style of   implies a width of zero], and vice versa. Also, when a width is zero, the units are also redundant, so you can simplify to either   or   I prefer the latter as the meaning is clear. -- Red rose64 &#x1f339; (talk) 11:34, 8 January 2017 (UTC)
 * I've changed all of them to ; thanks for explaining. Jc86035 (talk) Use &#123;&#123;re&#124;Jc86035&#125;&#125;

L-rail
I didn't see the notice, but it looks like l-rail replaced s-rail? Frietjes (talk) 18:16, 22 April 2018 (UTC)
 * News to me. Mackensen (talk) 18:17, 22 April 2018 (UTC)
 * Pinging, who created them yesterday. Is there something you might want to tell us about? Primefac (talk) 22:36, 22 April 2018 (UTC)
 * Yes, I mentioned that I hope to create a Lua version. However it is still quite rough now. Feedback is welcome. Szqecs (talk) 10:44, 23 April 2018 (UTC)

The primary issue with this right now, I think, is that this still doesn't seem to have enough advantages over the current set of templates (the transclusions look much the same), especially since it also adds disadvantages such as the current requirement to use mid and the need for many contributors to learn or improve Lua table skills even though they already know how to use switch parser functions (as well as the feature discrepancy). The only advantage, as far as I can tell, is that the data is all in one place, and this is probably not going to be enough and would also be considered reinventing the wheel. If you can make the table one template (e.g. like Routemap vs. BS-map, or like Infobox vs. wikitable code) and make it merge table cells automatically, then it will very likely be sufficiently better than the current system. Right now, the current system is slightly more inefficient but much easier to use and extend, and probably more useful overall. Take advantage of Lua's capabilities to make using the template as efficient and as painless as possible.


 * somehow get the table code generated from parameter input into Lua table structure, e.g. something like
 * for k, v in ipairs(data) do
 * if datak+1][left == v[left] then
 * tmp = k + 1
 * data[tmp[left]] = ''
 * rowspan = 2
 * (while loop iterate through data from tmp until ; each time the loop happens, erase data[tmp[left]] and then add 1 to   and to  ; when the while loop ends, prepend rowspan to data[k[left]] with  )
 * end
 * end
 * (repeat this for line columns and text column: replace  in previous text with a variable, maybe   where the whole loop is inside , to avoid duplicating code)
 * (do this for every contiguous group of data after each system header)

It shouldn't be too hard to change L-rail into a single template, especially since the groundwork for using arbitrarily numbered named parameters already exists in Module:Infobox (I re-used the code in Module:Routemap, incidentally, to allow more than ten maps). Avoiding per-article customizations such as row merges also makes using Wikidata data – at some point in the future – much easier.

Furthermore, I notice you've put a link function at the top of every data page. I don't think it's necessary, and I think using %s for a station name will probably be more intuitive and will be easier to explain in the template documentation (you should keep as much code as possible inside the main module, and the data pages should ideally have no functions so that they're easier to write – e.g. allowing the use of  table keys instead of needing a whole function).

Finally, I think it would be best to follow stylistic conventions such as putting commas before newlines so that it's easier for others to read your code (even though it's not strictly necessary to do so in Lua). Jc86035 (talk) 12:12, 23 April 2018 (UTC)


 * I'm lost. 1: What do you mean by 'merging cells' and 'arbitrarily numbered named parameters'? 2: What do you mean by using %s? Szqecs (talk) 12:58, 23 April 2018 (UTC)
 * By "merging cells" I meant usage of colspan and rowspan HTML attributes to combine table cells; an example exists at Template:S-line (several others further down the page). With the current S-line, rows1 etc. and hide1 etc. are used to manually specify cells which span more than one row. By "arbitrarily numbered parameters" (I apologize for using a vague term for something that doesn't actually have a name), I meant named parameters which are suffixed by a number which has no meaning other than to indicate the order of the data in the template; e.g. header1, label2, data2, etc. in Infobox.
 * I used %s in line with mw:Extension:Scribunto/Lua reference manual. For example, if, then   would produce the string  . More than one %s is supported. However, for this module I would use   or similar for this, since the only input to such a function would be the station name. There may be better ways to do this, but sticking a function inside the data table is probably unnecessarily complex for an editor who is never going to edit the main module itself.
 * Also, I notice that you haven't allowed for a link table for all lines. This capability (which is the default in the current template) would be quite useful, both for ease of use and for ease of importing existing data. Jc86035 (talk) 13:38, 23 April 2018 (UTC)
 * This stems from Template talk:S-line. Do you think it'd be necessary to modify the data structure to make the subpages easier to edit? Jc86035 (talk) 13:40, 23 April 2018 (UTC)
 * Merging cells is a feature I have yet implemented. It seems complex though.
 * My module does allow for multiple lines using arbitrarily numbered parameters, but not for multiple systems. This is because if the system parameter was treated the same way you would have to repeat it for the same system (e.g. TaipeiRTaipeiG).
 * Actually the link function is optional, and is used to make the module shorter. You could type all the Wikitext as is, but the data module would be huge and messy like Template:LUL stations. Using string.format seems like a good idea but I have no idea how it works, specifically the 'ISO C function sprintf' thing. Szqecs (talk) 14:38, 23 April 2018 (UTC)
 * I might work on the pseudocode (collapsed) above and see if it works. I don't think you would need to repeat the system's name: you could have it in system1, and then for every row thereafter until the next system n parameter, the system would be assumed to be system1 (e.g. system1, line2 (left2, right2, …), line3, line4, system5, line6, line7, …). I don't think this would be more complicated than the current system, especially since it's already been implemented in Module:Infobox.
 * ✅ Szqecs (talk) 11:47, 24 April 2018 (UTC)
 * I think keeping the links as plain wikitext internally would make it simpler – editors will be more used to the wikitext, and you don't actually need to escape any of the characters that you've escaped. As mentioned, string.format would probably be unnecessary (I don't really know completely how it works either) since you could just use the Lua regular expressions through mw.ustring.gsub for this particular module. Jc86035 (talk) 16:20, 23 April 2018 (UTC)
 * I think keeping the links as plain wikitext internally would make it simpler – editors will be more used to the wikitext, and you don't actually need to escape any of the characters that you've escaped. As mentioned, string.format would probably be unnecessary (I don't really know completely how it works either) since you could just use the Lua regular expressions through mw.ustring.gsub for this particular module. Jc86035 (talk) 16:20, 23 April 2018 (UTC)

Template-protected edit request on 23 April 2019
Please replace  with   to allow non-template-editors to develop documentation for this template. I have copied the current instruction and category over to the new /doc page. Thanks, --DannyS712 (talk) 02:28, 23 April 2019 (UTC)
 * ✅ Jc86035 (talk) 10:17, 23 April 2019 (UTC)

Northumberland Park Metro station
There is currently a discussion at Wikipedia talk:WikiProject UK Railways regarding a requested edit to this template. The thread is Northumberland Park in Tyne & Wear. Thank you. Thryduulf (talk) 14:26, 16 January 2024 (UTC)