From GamingWiki
Jump to: navigation, search
Line 34: Line 34:
 
   DATA
 
   DATA
  
We may have one, two or three label-data pairs.
+
We may have one, two or three label-data pairs (left, centre, right).
 +
We construct a hash, datalinehash, which maps each row number to data for the given row. The row data are serialized hashes. To generate these sub-hashes we look through all of the args to this template and find the ones that end in numbers. These are then saved as properties of the corresponding entry in datalinehash.
  
 
-->{{#hashdefine: datalinehash }}<!--
 
-->{{#hashdefine: datalinehash }}<!--
 
-->{{#forargs: | keynum | value | <!--
 
-->{{#forargs: | keynum | value | <!--
 +
 +
      Split the param (keynum) into a key name and a line number:
 
   -->{{#vardefine: key | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $1 }} }}<!--
 
   -->{{#vardefine: key | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $1 }} }}<!--
 
   -->{{#vardefine: num | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $2 }} }}<!--
 
   -->{{#vardefine: num | {{#rmatch: {{#var:keynum}} | (\D+)(\d+) | $2 }} }}<!--
Line 50: Line 53:
 
   -->{{#hashreset: singledataline}}<!--
 
   -->{{#hashreset: singledataline}}<!--
 
-->}}<!-- end forargs
 
-->}}<!-- end forargs
 +
 +
Now datalinehash should look something like:
 +
 +
  1 => "label;css;some label,css,data;css;data for line 1"
 +
  2 => "llabel;css;left-side label,css,ldata;css;line 2 left,css,rdata;css;line 2 right"
 +
  etc.
 +
  
 
   Now each value of datalinehash can be parsed into a new hash. We want it sorted by
 
   Now each value of datalinehash can be parsed into a new hash. We want it sorted by
Line 66: Line 76:
 
   -->}}<!--
 
   -->}}<!--
 
   -->{{#ifeq: {{#hashvalue: thedataline | label |M_NUL}}-{{#hashvalue: thedataline | data |M_NUL}} | <!--
 
   -->{{#ifeq: {{#hashvalue: thedataline | label |M_NUL}}-{{#hashvalue: thedataline | data |M_NUL}} | <!--
 +
      --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
 +
  -->}}<!--
 +
  -->{{#ifeq: {{#hashvalue: thedataline | clabel |M_NUL}}-{{#hashvalue: thedataline | cdata |M_NUL}} | <!--
 
       --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
 
       --> M_NUL-M_NUL || {{#vardefine: groupcount | {{#expr: {{#var:groupcount}}+1}} }} <!--
 
   -->}}<!--
 
   -->}}<!--
Line 75: Line 88:
 
   -->{{#ifeq:{{#var:groupcount}}|0||<!--
 
   -->{{#ifeq:{{#var:groupcount}}|0||<!--
  
         Here we're assuming there are 6 columns total:
+
         Here we're assuming there are 6 columns total.
 +
        @todo remove this assumption
 
       -->{{#vardefine:groupcols|2<!--
 
       -->{{#vardefine:groupcols|2<!--
 
         --><!--{{#switch: {{#var:groupcount}} | 1 = 6 | 2 = 3 | 3 = 2 | 6 }}--><!--
 
         --><!--{{#switch: {{#var:groupcount}} | 1 = 6 | 2 = 3 | 3 = 2 | 6 }}--><!--
Line 82: Line 96:
 
       -->{{#vardefine: llabelcols | {{#ifeq: {{#hashvalue: thedataline | llabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 
       -->{{#vardefine: llabelcols | {{#ifeq: {{#hashvalue: thedataline | llabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 
       -->{{#vardefine: labelcols  | {{#ifeq: {{#hashvalue: thedataline | label  |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 
       -->{{#vardefine: labelcols  | {{#ifeq: {{#hashvalue: thedataline | label  |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 +
      -->{{#vardefine: clabelcols | {{#ifeq: {{#hashvalue: thedataline | clabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 
       -->{{#vardefine: rlabelcols | {{#ifeq: {{#hashvalue: thedataline | rlabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
 
       -->{{#vardefine: rlabelcols | {{#ifeq: {{#hashvalue: thedataline | rlabel |M_NUL}} | M_NUL | 0 | 1 }} }}<!--
  
Line 94: Line 109:
 
         -->}}<!--
 
         -->}}<!--
 
       -->}}<!--
 
       -->}}<!--
       -->{{#vardefine: datacols | {{#expr:{{#var:columns}}-{{#var:labelcols}}-{{#var:llabelcols}}-{{#var:ldatacols}}-{{#var:rlabelcols}}-{{#var:rdatacols}} }} }}<!--
+
       -->{{#vardefine: cdatacols | {{#expr:{{#var:columns}}-{{#var:labelcols}}-{{#var:clabelcols}}-{{#var:llabelcols}}-{{#var:ldatacols}}-{{#var:rlabelcols}}-{{#var:rdatacols}} }} }}<!--
 +
      -->{{#vardefine: datacols  | {{#var:cdatacols}} }}<!--
  
 
       --><nowiki />
 
       --><nowiki />
Line 104: Line 120:
  
 
       -->{{#ifeq: {{#var: ldatacols}} | 0 | |<nowiki />
 
       -->{{#ifeq: {{#var: ldatacols}} | 0 | |<nowiki />
{{!}} class="{{#hashvalue: thedataline|dataclass|}} {{#hashvalue: thedataline | ldataclass }}" {{!}} {{#hashvalue: thedataline | ldata }} <!--
+
{{!}} class="{{#hashvalue: thedataline|dataclass|}} {{#hashvalue: thedataline | ldataclass }} ldata" {{!}} {{#hashvalue: thedataline | ldata }} <!--
 
       -->}}<!--
 
       -->}}<!--
  

Revision as of 22:23, 13 May 2014