Test: Difference between revisions

522 bytes removed ,  27 March 2008
update on foreach and expression parsing: foreach sayonara, expr arigato
(testing lowercase)
(update on foreach and expression parsing: foreach sayonara, expr arigato)
Line 5: Line 5:
:[[User:Geyser|geyser]], deprived of laptop and ICQ for a while ^^ ... which explains the "born to nag" attitude.
:[[User:Geyser|geyser]], deprived of laptop and ICQ for a while ^^ ... which explains the "born to nag" attitude.
;Foreach
;Foreach
{| border="1" cellspacing="0" cellpadding="0" style="empty-cells:show;"
:A multi-recursive transclusion hack that allowed one to auto-generate lists with "any" number of items, tables with "any" number of columns, etc. It used to be authoritative, but because of the server load it generates, it's been banned from Wikipedia and is not supported by Mediawiki by default. So we're not bringing it back. Here are alternatives [[User:geyser|I]] proposed to Alloc in response to his use of "foreach" (the object represented has to do with another project hosted on another wiki).
| colspan="29" | 29 Bit CAN-ID
|-
{{foreach |29|||||||22|  pc1=1=yellow  |call=ProtokollTabelleBit|pv=2}}
{{foreach |21|            pc1=1=fuchsia |call=ProtokollTabelleBit|pv=2}}
{{foreach |20|||||||||11| pc1=1=lime    |call=ProtokollTabelleBit|pv=2}}
{{foreach |10|||||||||1|  pc1=1=aqua    |call=ProtokollTabelleBit|pv=2}}
|-
| {{ProtokollTabelleDef|yellow|8|Port}}
| {{ProtokollTabelleDef|fuchsia|1|3==0}}
| {{ProtokollTabelleDef|lime|10|Ziel-Adresse}}
| {{ProtokollTabelleDef|aqua|10|Absender-Adresse}}
|}
:That solution is universal, and sorta authoritative, but it takes ''ages'' for the engine to evaluate : in any given situation, one should probably prefer a lighter, more specific solution.
 
 
;How about this?
;How about this?
{|{{TightTable}}
{|{{TightTable}}
Line 38: Line 23:
:The "skipped bits" span of every chunk is specified in pixels, which can be handy in case one wants a more compact layout. The non-breaking space can then be replaced with a "..." to avoid confusion.
:The "skipped bits" span of every chunk is specified in pixels, which can be handy in case one wants a more compact layout. The non-breaking space can then be replaced with a "..." to avoid confusion.
:I think the skipped widths are best let custom, as well as the "header". Apart from arbitrarily shrinking the skip fields, one may want to rephrase the header, or omit it, or make it a caption :
:I think the skipped widths are best let custom, as well as the "header". Apart from arbitrarily shrinking the skip fields, one may want to rephrase the header, or omit it, or make it a caption :
{|{{TightTable}}
{|{{TightTable}} style="white-space:nowrap"
|+'''29-Bit CAN-ID
|+'''29-Bit CAN-ID
|
|
Line 57: Line 42:
:The template would then evaluate the difference, and decide upon a 1-bit, or on a 2-plus-bit layout with an adequate skip.
:The template would then evaluate the difference, and decide upon a 1-bit, or on a 2-plus-bit layout with an adequate skip.
:However, the markup is a bit heavier, and makes a few assumptions about e.g. the order in which the bits are listed (unless one wants to emulate '''abs''', which is a little bit heavier still).
:However, the markup is a bit heavier, and makes a few assumptions about e.g. the order in which the bits are listed (unless one wants to emulate '''abs''', which is a little bit heavier still).
:Right now, it produces a fatal error parsing '''Expr.php''' (then again, so does <nowiki>{{#expr:2+2}}</nowiki>, so there ''is'' a problem), but it would look something like this :
{|{{TightTable}} style="white-space:nowrap"
<nowiki>{|{{</nowiki>TightTable|color={{{4}}}}}
|+'''29-Bit CAN-ID
|-align=center
|
|width=18|{{{1}}}
{{ProtoBits2|29|22|Port|yellow}}
|-
|
<nowiki>|width={{#ifexpr:{{{1}}}>{{{2}}}|{{#expr:18*({{{1}}}-{{{2}}}-1)}}|0}}|{{#ifexpr:{{{1}}}>{{{2}}}+1|...|}}</nowiki>
{{ProtoBits2|21|21|<nowiki>=</nowiki>0|fuchsia}}
<nowiki>|width={{#ifexpr:{{{1}}}>{{{2}}}|18|0}}|{{#ifexpr:{{{1}}}>{{{2}}}|{{{2}}}|}}</nowiki>
|
|colspan=3|{{{3}}}
{{ProtoBits2|20|11|Ziel-Adresse|lime}}
|}
|
 
{{ProtoBits2|10|1|Absender-Adresse|aqua}}
 
|}
;CAN-ID table
;CAN-ID table
:It ''could'' be possible to embed the chunk tables into a big template table specific to the "29-Bit CAN-ID" usage, but most components would have to be in HTML. Bad idea.
:It ''could'' be possible to embed the chunk tables into a big template table specific to the "29-Bit CAN-ID" usage, but most components might have to be in HTML. Bad idea.