matcornic/hermes

hermes.Theme has no support for exported fields

juliusmh opened this issue · 0 comments

Given a Theme like this:

type Theme struct {
    Color string
    Logo  string
}

func (t *Theme) Name() string { ... }
func (t *Theme) HTMLTemplate() string { ... }
func (t *Theme) PlainTextTemplate() string { ... }

And calling hermes like this:

h := hermes.Hermes{
    Theme: new(Theme),
    // ...
}
email := hermes.Email{
    //  ...
}
html, err = h.GenerateHTML(email)
if err != nil {
	...
}

Will result int

panic: reflect: Field index out of range [recovered]
	panic: reflect: Field index out of range

The reason for this is the exported fields, which are tried to be merged into hermes.Default theme which is of type struct{}. Therefore it's not possible to have exported fields on a struct implementing hermes.Theme interface.