Created
December 27, 2024 14:43
-
-
Save librasteve/abceefcf62349c4c93259484c813eec9 to your computer and use it in GitHub Desktop.
MyCromps-Thead.rakumod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cell is export { | |
has $.data is required; | |
multi method new($data) { | |
$.new: :$data | |
} | |
method RENDER { | |
q:to/END/ | |
<td><.data></td> | |
END | |
} | |
} | |
class Row is export { | |
has Cell() @.cells is required; | |
multi method new(@cells) { | |
$.new: :@cells | |
} | |
method RENDER { | |
q:to/END/ | |
<tr> | |
<@.cells: $c> | |
<&Cell($c)> | |
</@> | |
</tr> | |
END | |
} | |
} | |
class HCell is export { | |
has $.data is required; | |
multi method new($data) { | |
$.new: :$data | |
} | |
method RENDER { | |
q:to/END/ | |
<th><.data></th> | |
END | |
} | |
} | |
class THead is export { | |
has HCell() @.cells is required; | |
multi method new(@cells) { | |
$.new: :@cells | |
} | |
method RENDER { | |
q:to/END/ | |
<thead> | |
<tr> | |
<@.cells: $c> | |
<&HCell($c)> | |
</@> | |
</tr> | |
</thead> | |
END | |
} | |
} | |
class MyTable is export { | |
has Row() @.rows is required; | |
has THead() $.thead; | |
multi method new(@rows, *%_) { | |
$.new: :@rows, |%_ | |
} | |
method RENDER { | |
q:to/END/ | |
<table class="striped"> | |
<?.thead> | |
<&THead(.thead)> | |
</?> | |
<tbody> | |
<@.rows: $r> | |
<&Row($r)> | |
</@> | |
</tbody> | |
</table> | |
END | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment