@@ -2,68 +2,57 @@ package html
2
2
3
3
import "strconv"
4
4
5
- func Tr [T * TableHeader | * TableData ](element ... T ) * Element {
5
+ var _ HTMLer = new (TableCell )
6
+
7
+ type TableCell struct { * Element }
8
+
9
+ func Tr (element ... * TableCell ) * Element {
6
10
tr := NewElement ("tr" )
7
11
for _ , i := range element {
8
12
tr .AppendContent (i )
9
13
}
10
14
return tr
11
15
}
12
16
13
- var (
14
- _ HTMLer = new (TableHeader )
15
- _ HTMLer = new (TableData )
16
- )
17
-
18
- type (
19
- TableHeader struct { * Element }
20
- TableData struct { * Element }
21
- )
22
-
23
- func Th (content any ) * TableHeader {
24
- return & TableHeader {NewElement ("th" ).Content (content )}
25
- }
26
-
27
- func (th * TableHeader ) Abbr (abbr string ) * TableHeader {
28
- th .Element .Attribute ("abbr" , abbr )
29
- return th
17
+ func Th (content any ) * TableCell {
18
+ return & TableCell {NewElement ("th" ).Content (content )}
30
19
}
31
20
32
- func (th * TableHeader ) Colspan (n uint ) * TableHeader {
33
- th .Element .Attribute ("colspan" , strconv .FormatUint (uint64 (n ), 10 ))
34
- return th
21
+ func Td (content any ) * TableCell {
22
+ return & TableCell {NewElement ("td" ).Content (content )}
35
23
}
36
24
37
- func (th * TableHeader ) Headers ( headers string ) * TableHeader {
38
- th .Element .Attribute ("headers " , headers )
39
- return th
25
+ func (cell * TableCell ) Abbr ( abbr string ) * TableCell {
26
+ cell .Element .Attribute ("abbr " , abbr )
27
+ return cell
40
28
}
41
29
42
- func (th * TableHeader ) Rowspan (n uint ) * TableHeader {
43
- th .Element .Attribute ("rowspan " , strconv .FormatUint (uint64 (n ), 10 ))
44
- return th
30
+ func (cell * TableCell ) Colspan (n uint ) * TableCell {
31
+ cell .Element .Attribute ("colspan " , strconv .FormatUint (uint64 (n ), 10 ))
32
+ return cell
45
33
}
46
34
47
- func (th * TableHeader ) Scope ( scope string ) * TableHeader {
48
- th .Element .Attribute ("scope " , scope )
49
- return th
35
+ func (cell * TableCell ) Headers ( headers string ) * TableCell {
36
+ cell .Element .Attribute ("headers " , headers )
37
+ return cell
50
38
}
51
39
52
- func Td (content any ) * TableData {
53
- return & TableData {NewElement ("td" ).Content (content )}
40
+ func (cell * TableCell ) Rowspan (n uint ) * TableCell {
41
+ cell .Element .Attribute ("rowspan" , strconv .FormatUint (uint64 (n ), 10 ))
42
+ return cell
54
43
}
55
44
56
- func (td * TableData ) Colspan ( n uint ) * TableData {
57
- td .Element .Attribute ("colspan " , strconv . FormatUint ( uint64 ( n ), 10 ) )
58
- return td
45
+ func (cell * TableCell ) Scope ( scope string ) * TableCell {
46
+ cell .Element .Attribute ("scope " , scope )
47
+ return cell
59
48
}
60
49
61
- func (td * TableData ) Headers ( headers string ) * TableData {
62
- td .Element .Attribute ( "headers" , headers )
63
- return td
50
+ func (cell * TableCell ) Class ( class ... string ) * TableCell {
51
+ cell .Element .Class ( class ... )
52
+ return cell
64
53
}
65
54
66
- func (td * TableData ) Rowspan ( n uint ) * TableData {
67
- td .Element .Attribute ( "rowspan" , strconv . FormatUint ( uint64 ( n ), 10 ) )
68
- return td
55
+ func (cell * TableCell ) Style ( style string ) * TableCell {
56
+ cell .Element .Style ( style )
57
+ return cell
69
58
}
0 commit comments