Difference between revisions of "Template:Card table"
Dinoguy1000 (talk | contribs) (fix parser function) |
Dinoguy1000 (talk | contribs) (document the image validation stuff in a comment; support up to 20 rows instead of just 15 (needed for {{Anime card}} and I think it'll be needed for CT2 as well)) |
||
Line 1: | Line 1: | ||
− | {{ #if: {{{ | + | {{ #if: {{{header21|}}}{{{headerstyle21|}}}{{{label21|}}}{{{labelstyle21|}}}{{{data21|}}}{{{datastyle21|}}}{{{class21|}}}{{{rowclass21|}}} |
| <div class="error">Error: too many rows!</div>[[Category:Card table transclusions with too many rows]] | | <div class="error">Error: too many rows!</div>[[Category:Card table transclusions with too many rows]] | ||
− | }}{{ #if: {{{image_raw|}}} || {{ #vardefine: $ct_img | {{PAGENAME:{{{image|}}}}} | + | }}<!-- |
+ | |||
+ | image validation code | ||
+ | |||
+ | the width validation especially is pretty convoluted, so here's what it's trying to do (ignoring most error checking): | ||
+ | * <max width> is 200px | ||
+ | * this can be overwritten with {{{max_width(_right)}}}, but this has a hardcoded maximum of 400px | ||
+ | * check if an image's <native width> is less than <max width> | ||
+ | * if there's a <specified width>, check that it's smaller than <max width> and larger than 0px | ||
+ | * if there's a valid <specified width>, use it; otherwise, use the smaller of <native width> or <max width> | ||
+ | |||
+ | the image itself is also confirmed to exist, by checking if its <native width> is 0px; if so, a default backing image (File:Back-EN.png) is used instead, with a link to the upload form for the specified image | ||
+ | |||
+ | -->{{ #if: {{{image_raw|}}} || {{ #vardefine: $ct_img | {{PAGENAME:{{{image|}}}}} | ||
}}{{ #if: {{ #var: $ct_img }} | {{ #ifeq: {{ #imgw: {{ #var: $ct_img }} }} | 0 | {{ #vardefine: $ct_img_name | {{ #var: $ct_img }} }}{{ #vardefine: $ct_img | Back-EN.png }} }} | }}{{ #if: {{ #var: $ct_img }} | {{ #ifeq: {{ #imgw: {{ #var: $ct_img }} }} | 0 | {{ #vardefine: $ct_img_name | {{ #var: $ct_img }} }}{{ #vardefine: $ct_img | Back-EN.png }} }} | ||
}}{{ #vardefine: $ct_max_width | {{px|{{{max_width}}}}} | }}{{ #vardefine: $ct_max_width | {{px|{{{max_width}}}}} | ||
Line 112: | Line 125: | ||
|data={{{data15|}}} |datastyle={{{datastyle|}}} {{{datastyle15|}}} | |data={{{data15|}}} |datastyle={{{datastyle|}}} {{{datastyle15|}}} | ||
|class={{{class15|}}} |rowclass={{{rowclass15|}}} | |class={{{class15|}}} |rowclass={{{rowclass15|}}} | ||
+ | }}{{Infobox/row | ||
+ | |header={{{header16|}}} |headerstyle={{{headerstyle|}}}{{{headerstyle16|}}} | ||
+ | |label={{{label16|}}} |labelstyle={{{labelstyle|}}} {{{labelstyle16|}}} | ||
+ | |data={{{data16|}}} |datastyle={{{datastyle|}}} {{{datastyle16|}}} | ||
+ | |class={{{class16|}}} |rowclass={{{rowclass16|}}} | ||
+ | }}{{Infobox/row | ||
+ | |header={{{header17|}}} |headerstyle={{{headerstyle|}}}{{{headerstyle17|}}} | ||
+ | |label={{{label17|}}} |labelstyle={{{labelstyle|}}} {{{labelstyle17|}}} | ||
+ | |data={{{data17|}}} |datastyle={{{datastyle|}}} {{{datastyle17|}}} | ||
+ | |class={{{class17|}}} |rowclass={{{rowclass17|}}} | ||
+ | }}{{Infobox/row | ||
+ | |header={{{header18|}}} |headerstyle={{{headerstyle|}}}{{{headerstyle18|}}} | ||
+ | |label={{{label18|}}} |labelstyle={{{labelstyle|}}} {{{labelstyle18|}}} | ||
+ | |data={{{data18|}}} |datastyle={{{datastyle|}}} {{{datastyle18|}}} | ||
+ | |class={{{class18|}}} |rowclass={{{rowclass18|}}} | ||
+ | }}{{Infobox/row | ||
+ | |header={{{header19|}}} |headerstyle={{{headerstyle|}}}{{{headerstyle19|}}} | ||
+ | |label={{{label19|}}} |labelstyle={{{labelstyle|}}} {{{labelstyle19|}}} | ||
+ | |data={{{data19|}}} |datastyle={{{datastyle|}}} {{{datastyle19|}}} | ||
+ | |class={{{class19|}}} |rowclass={{{rowclass19|}}} | ||
+ | }}{{Infobox/row | ||
+ | |header={{{header20|}}} |headerstyle={{{headerstyle|}}}{{{headerstyle20|}}} | ||
+ | |label={{{label20|}}} |labelstyle={{{labelstyle|}}} {{{labelstyle20|}}} | ||
+ | |data={{{data20|}}} |datastyle={{{datastyle|}}} {{{datastyle20|}}} | ||
+ | |class={{{class20|}}} |rowclass={{{rowclass20|}}} | ||
}} | }} | ||
</table> | </table> |
Revision as of 15:52, 27 May 2018
{{{title}}}
{{{above}}}
{{{above_image}}}
[[File:|0px|link=File:]]
{{{below_image}}}
{{{below}}}
This template uses Lua: |
{{Card table}} is a metatemplate used to create card table templates.
Usage
Example
{{Card table | title = {{ #if: {{{title|}}} | {{{title}}} | {{PAGENAME}} }} | image = {{ #if: {{{image|}}} | {{{image}}} | Back-EN.png }} | label1 = [[Attribute]] | data1 = [[{{uc:{{{attribute}}}}}]] [[File:{{uc:{{{attribute}}}}}.svg|25px|alt=]] | label2 = [[Level]] | data2 = {{{level}}} {{Repeat|[[File:CG Star.svg|18px|alt=]]|{{{level}}}}} | label3 = [[Type|Type(s)]] | data3 = {{Card table/types|{{{types}}}|{{{effect_types|}}}|linked}} | label4 = [[ATK]]/[[DEF]] | data4 = {{{atk}}}/{{{def}}} | data5 = <div class="lore">{{{lore}}}</div> | label6 = Effect types | data6 = {{{effect types|}}} | label7 = Status | data7 = {{{status}}} }}