Difference between revisions of "Template:JKR"

From blackwiki
Jump to navigation Jump to search
imported>WOSlinker
(swap order of svg and png checking to reduce expensive parser function calls since more png and svg files exist)
imported>Johnuniq
(accept parameter 2 to reduce number of expensive parser calls per WP:VPT discussion)
Line 1: Line 1:
 
{{#switch:{{ucfirst:{{padleft:|1|{{{1|}}}}}}}
 
{{#switch:{{ucfirst:{{padleft:|1|{{{1|}}}}}}}
 
|E = {{error|Wrong template: use {{tlp|MES-E|''route number without "E"''}}}}
 
|E = {{error|Wrong template: use {{tlp|MES-E|''route number without "E"''}}}}
|A |B |C |D |J |K |M |N |P |Q |R |S |T |1 |2 |3 |4 |5 |6 |7 |8 |9 = {{#ifexist:Media:Jkr-ft{{{1}}}.png|[[File:Jkr-ft{{{1}}}.png|30px|link=]]|{{#ifexist:Media:Jkr-ft{{{1}}}.svg|[[File:Jkr-ft{{{1}}}.svg|30px|link=]]|''{{{1|}}}''}}}}
+
|A |B |C |D |J |K |M |N |P |Q |R |S |T |1 |2 |3 |4 |5 |6 |7 |8 |9 = {{#switch:{{{2|}}}
|- |– =  
+
|png = [[File:Jkr-ft{{{1}}}.png|30px]]
 +
|svg = [[File:Jkr-ft{{{1}}}.svg|30px|link=]]
 +
|text = ''{{{1|}}}''
 +
|{{#ifexist:Media:Jkr-ft{{{1}}}.png|[[File:Jkr-ft{{{1}}}.png|30px|link=]]|{{#ifexist:Media:Jkr-ft{{{1}}}.svg|[[File:Jkr-ft{{{1}}}.svg|30px|link=]]|''{{{1|}}}''}}}}
 +
}}
 +
|- |– =
 
|#default = <includeonly>{{error|Invalid route number}}</includeonly>
 
|#default = <includeonly>{{error|Invalid route number}}</includeonly>
 
}}<noinclude>
 
}}<noinclude>
 
{{Documentation}}
 
{{Documentation}}
 
<noinclude>
 
<noinclude>

Revision as of 08:24, 2 February 2019

Template documentation[view] [edit] [history] [purge]

This template displays the route marker for Malaysian roads given the route number. If the proper image does not exist on this wiki or Wikimedia Commons, the template will display the route number in italics until the image is uploaded. This template does not currently work for expressway routes and will display an error instead.

Examples

  • {{JKR|1}}Jkr-ft1.png
  • {{JKR|9999}}9999
  • {{JKR|P1}}P1
  • {{JKR|E40}}Wrong template: use {{MES-E|route number without "E"}}

Specifying output

Some pages (example) use this template many times. To avoid errors due to the large number of expensive function calls to test which images exist, an optional second parameter can be added:

  • svg to use the svg image
  • png to use the png image
  • text to use italic text

Examples:

  • {{JKR|1|svg}}Jkr-ft1.svg
  • {{JKR|1|png}}Jkr-ft1.png
  • {{JKR|1|text}}1