Skip to content

Commit

Permalink
Merge pull request #8 from gochore/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfogre authored Jun 18, 2020
2 parents 3d6c434 + 97688ac commit 050d66d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions element.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion element_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
2 changes: 1 addition & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (t *Table) Render(writer io.Writer, themes ...style.Theme) error {
render.Println("<tr>")
for _, column := range columns {
render.Printlnf("<td %s>", theme.Attributes("td"))
e := TemplateElement{
e := Template{
Data: dataset.Index(i),
Template: column.Template,
Funcs: t.funcs,
Expand Down

0 comments on commit 050d66d

Please sign in to comment.