Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hermes.Theme has no support for exported fields #84

Open
juliusmh opened this issue Nov 3, 2021 · 0 comments
Open

hermes.Theme has no support for exported fields #84

juliusmh opened this issue Nov 3, 2021 · 0 comments

Comments

@juliusmh
Copy link

juliusmh commented Nov 3, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant