@@ -36,21 +36,28 @@ func TestTable(t *testing.T) {
36
36
if td .HasArg ("horizontally" ) {
37
37
opts .Orientation = Horizontally
38
38
}
39
+ align := AlignRight
40
+ if td .HasArg ("left" ) {
41
+ align = AlignLeft
42
+ }
43
+ if td .HasArg ("center" ) {
44
+ align = AlignCenter
45
+ }
39
46
switch td .Cmd {
40
47
case "cats-autoincrement" :
41
48
def := Define [Cat ](
42
49
AutoIncrement [Cat ]("idx" , 3 , AlignLeft ),
43
50
Div (),
44
- String ("name" , 7 , AlignRight , func (c Cat ) string { return c .Name }),
51
+ String ("name" , 7 , align , func (c Cat ) string { return c .Name }),
45
52
)
46
53
wb .Reset (1 )
47
54
def .Render (wb .At (0 , 0 ), opts , slices .Values (cats ))
48
55
return wb .String ()
49
56
case "cats-nodiv" :
50
57
def := Define [Cat ](
51
58
String ("name" , 6 , AlignLeft , func (c Cat ) string { return c .Name }),
52
- Int ("age" , 3 , AlignRight , func (c Cat ) int { return c .Age }),
53
- Int ("cuteness" , 8 , AlignRight , func (c Cat ) int { return c .Cuteness }),
59
+ Int ("age" , 3 , align , func (c Cat ) int { return c .Age }),
60
+ Int ("cuteness" , 8 , align , func (c Cat ) int { return c .Cuteness }),
54
61
)
55
62
wb .Reset (1 )
56
63
def .Render (wb .At (0 , 0 ), opts , slices .Values (cats ))
@@ -63,8 +70,8 @@ func TestTable(t *testing.T) {
63
70
def := Define [Cat ](
64
71
String ("name" , 6 , AlignLeft , func (c Cat ) string { return c .Name }),
65
72
Div (),
66
- Int ("age" , 3 , AlignRight , func (c Cat ) int { return c .Age }),
67
- Int ("c" , 1 , AlignRight , func (c Cat ) int { return c .Cuteness }),
73
+ Int ("age" , 3 , align , func (c Cat ) int { return c .Age }),
74
+ Int ("c" , 1 , align , func (c Cat ) int { return c .Cuteness }),
68
75
)
69
76
wb .Reset (1 )
70
77
def .Render (wb .At (0 , 0 ), opts , slices .Values (c ))
0 commit comments