Template:ArmorTable.dpl: Difference between revisions
From HorizonXI Wiki
m (if no stats are given in item statistics, show ''None'') |
(allowed linebreak in jobs column and added to the documentation) |
||
Line 3: | Line 3: | ||
| align=center | {{{slot}}} | | align=center | {{{slot}}} | ||
| align=center | {{#if: {{{jobs|}}}|{{trim|<!-- | | align=center | {{#if: {{{jobs|}}}|{{trim|<!-- | ||
-->{{#replace:<!-- | |||
-->{{#replace:<!-- | -->{{#replace:<!-- | ||
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!-- | -->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!-- | ||
-->|<br/>|<nowiki/> <nowiki/>}}<!-- | -->|<br/>|<nowiki/> <nowiki/>}}<!-- | ||
-->}}|All Jobs}} | -->|]]/|]]/<wbr>}}}}|All Jobs}} | ||
| {{#if:{{{stats|}}}|{{trim|<!-- | | {{#if:{{{stats|}}}|{{trim|<!-- | ||
-->{{#replace:<!-- | -->{{#replace:<!-- | ||
Line 25: | Line 26: | ||
| align=center | {{{slot}}} | | align=center | {{{slot}}} | ||
| align=center | {{#if: {{{jobs|}}}|{{trim|<!-- | | align=center | {{#if: {{{jobs|}}}|{{trim|<!-- | ||
-->{{#replace:<!-- | |||
-->{{#replace:<!-- | -->{{#replace:<!-- | ||
-->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!-- | -->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!-- | ||
-->|<br/>|<nowiki/> <nowiki/>}}<!-- | -->|<br/>|<nowiki/> <nowiki/>}}<!-- | ||
-->}}|All Jobs}} | -->|]]/|]]/<wbr>}}}}|All Jobs}} | ||
|{{trim|<!-- | | {{#if:{{{stats|}}}|{{trim|<!-- | ||
-->{{#replace:<!-- | -->{{#replace:<!-- | ||
-->{{#replace:{{{stats}}}|<br>|<nowiki/> <nowiki/>}}<!-- | -->{{#replace:{{{stats}}}|<br>|<nowiki/> <nowiki/>}}<!-- | ||
-->|<br/>|<nowiki/> <nowiki/>}}<!-- | -->|<br/>|<nowiki/> <nowiki/>}}<!-- | ||
-->}}</pre> | -->}}|''None''}}</pre> | ||
===Code Explanation=== | ===Code Explanation=== | ||
Line 42: | Line 44: | ||
* '''<nowiki>{{{slot}}}</nowiki>''' is simply returned as is. There is no armor without it. | * '''<nowiki>{{{slot}}}</nowiki>''' is simply returned as is. There is no armor without it. | ||
* '''<nowiki>{{{jobs}}}</nowiki>''' and '''<nowiki>{{{stats}}}</nowiki>''' needed some extra work: jobs are usually manually put into new lines by using the html < br> or < br/>. Each of those get replaced with a whitespace (the < nowiki/> < nowiki/>) and in the end, the <nowiki>{{trim}}</nowiki> template will remove all excessive whitespace. | * '''<nowiki>{{{jobs}}}</nowiki>''' and '''<nowiki>{{{stats}}}</nowiki>''' needed some extra work: jobs are usually manually put into new lines by using the html < br> or < br/>. Each of those get replaced with a whitespace (the < nowiki/> < nowiki/>) and in the end, the <nowiki>{{trim}}</nowiki> template will remove all excessive whitespace. | ||
** Fallback if no <nowiki>{{{jobs}}}</nowiki> is given is to display "All Jobs" | **<nowiki>{{{jobs}}} additionally replaces / with /<wbr>, where the <wbr> is a html code for a possible linebreak. The actual rule being ]]/ being replaced with ]]/<wbr> is to make sure that it only catches slashes after links</nowiki> | ||
** Fallback if no <nowiki>{{{jobs}}}</nowiki> is given is to display "All Jobs". For <nowiki>{{{stats}}}</nowiki>, the fallback for no entry is ''None''. | |||
==Example from ArmorTable== | ==Example from ArmorTable== | ||
{{ArmorTable|title1=Evoker's Spats}} | {{ArmorTable|title1=Evoker's Spats}} | ||
{{ArmorTable|title1=Serene Ring}} |
Latest revision as of 18:07, 17 November 2024
Documentation
This is a phantom template for a dpl3 call in Template:ArmorTable which takes arguments from Template:Item Statistics.
The basic idea is that Template:ArmorTable will display information based on parameters of Template:Item Statistics. This phantom template takes the arguments from Template:Item Statistics, manipulates them and then produces an output with | as separator because the output is intended to be used as a row in a table. Template:ArmorTable generates this table.
See Template:WeaponsTable.dpl for the analoguous table for weapons.
Code
align=center | {{#ifeq: {{#len:{{{level}}}}} | 1 | {{{level}}} | {{{level}}}}} | align=center | {{{slot}}} | align=center | {{#if: {{{jobs|}}}|{{trim|<!-- -->{{#replace:<!-- -->{{#replace:<!-- -->{{#replace:{{{jobs}}}|<br>|<nowiki/> <nowiki/>}}<!-- -->|<br/>|<nowiki/> <nowiki/>}}<!-- -->|]]/|]]/<wbr>}}}}|All Jobs}} | {{#if:{{{stats|}}}|{{trim|<!-- -->{{#replace:<!-- -->{{#replace:{{{stats}}}|<br>|<nowiki/> <nowiki/>}}<!-- -->|<br/>|<nowiki/> <nowiki/>}}<!-- -->}}|''None''}}
Code Explanation
(There are a lot of html comment < !-- and -- > in there. Their only purpose is to structure the code and they have no effect on the output)
- The {{{level}}} line. If returning just {{{level}}}, the sorting of the table by that column would be wrong. dpl can only sort alphabetically and not numerically, therefore, single digit numbers get mixed up with multidigit numbers since it sorts by first digit, then by second digit and so on. To circumvent this, we check if {{{level}}} is a one digit number. If it is, insert a blank space html code (& nbsp;). Since html is rendered after mediawiki templates, the & is considered the first digit and will thereby cause all single digit numbers to be sorted above all two digit numbers.
- {{{slot}}} is simply returned as is. There is no armor without it.
- {{{jobs}}} and {{{stats}}} needed some extra work: jobs are usually manually put into new lines by using the html < br> or < br/>. Each of those get replaced with a whitespace (the < nowiki/> < nowiki/>) and in the end, the {{trim}} template will remove all excessive whitespace.
- {{{jobs}}} additionally replaces / with /<wbr>, where the <wbr> is a html code for a possible linebreak. The actual rule being ]]/ being replaced with ]]/<wbr> is to make sure that it only catches slashes after links
- Fallback if no {{{jobs}}} is given is to display "All Jobs". For {{{stats}}}, the fallback for no entry is None.
Example from ArmorTable
Name | Level | Slot | Jobs | Stats | Horizon Changes |
---|---|---|---|---|---|
Evoker's Spats | 52 | Legs | SMN | DEF: 25 MP +15 Evasion skill +10 Avatar: Enhances accuracy Enmity -2 |
none
|
Name | Level | Slot | Jobs | Stats | Horizon Changes |
---|---|---|---|---|---|
Serene Ring | 69 | Ring | WHM/ |
INT +2 MND +2 CHR +2 Converts 15 HP to MP Enmity -2 |
none
|