diff --git a/element.go b/element.go index 2db8a7d..3cd1145 100644 --- a/element.go +++ b/element.go @@ -14,14 +14,14 @@ type Element interface { Render(writer io.Writer, themes ...style.Theme) error } -type TemplateElement struct { +type Template struct { Data interface{} Template string Funcs template.FuncMap } -func (e TemplateElement) Render(writer io.Writer, themes ...style.Theme) error { - errPrefix := "TemplateElement.Render: " +func (e Template) Render(writer io.Writer, themes ...style.Theme) error { + errPrefix := "Template.Render: " t, err := template.New("").Funcs(e.Funcs).Parse(e.Template) if err != nil { diff --git a/element_test.go b/element_test.go index 1af8267..b9aa03c 100644 --- a/element_test.go +++ b/element_test.go @@ -79,7 +79,7 @@ func TestTemplateElement_Render(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - e := TemplateElement{ + e := Template{ Data: tt.fields.Data, Template: tt.fields.Template, Funcs: tt.fields.Funcs, diff --git a/email.go b/email.go index 3128eef..8c51632 100644 --- a/email.go +++ b/email.go @@ -31,7 +31,7 @@ func NewEmail(options ...Option) *Email { return ret } -func (e *Email) AddElements(element ...Element) *Email { +func (e *Email) Add(element ...Element) *Email { e.elements = append(e.elements, element...) return e } diff --git a/email_test.go b/email_test.go index f1017dd..9ba93d1 100644 --- a/email_test.go +++ b/email_test.go @@ -62,7 +62,7 @@ func TestEmail_Render(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - e := NewEmail().AddElements(tt.fields.elements...) + e := NewEmail().Add(tt.fields.elements...) got := bytes.NewBuffer(nil) err := e.Render(got) if (err != nil) != tt.wantErr { diff --git a/list.go b/list.go index ac71dd8..54147a2 100644 --- a/list.go +++ b/list.go @@ -13,11 +13,11 @@ type List struct { ordered bool } -func NewUnorderedList() *List { +func NewUnordered() *List { return &List{} } -func NewOrderedList() *List { +func NewOrdered() *List { return &List{ ordered: true, } diff --git a/list_test.go b/list_test.go index fbfb51e..f14c58f 100644 --- a/list_test.go +++ b/list_test.go @@ -55,9 +55,9 @@ func TestList_Render(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - l := NewUnorderedList() + l := NewUnordered() if tt.fields.ordered { - l = NewOrderedList() + l = NewOrdered() } l.Add(tt.fields.items...) writer := &bytes.Buffer{} diff --git a/table.go b/table.go index 6658e5a..63ccde1 100644 --- a/table.go +++ b/table.go @@ -115,7 +115,7 @@ func (t *Table) Render(writer io.Writer, themes ...style.Theme) error { render.Println("