hermes.Theme has no support for exported fields
- Dominant language
- Go
- Stars
- 3k
- Forks
- 249
- PR merge metrics
- No merged PRs in 30d
Description
Given a Theme like this:
```go
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:
```go
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.
Contributor guide
Research direction
Reproduce the panic with the exported-field Theme example and h.GenerateHTML(email), then inspect the theme-merging path involving hermes.Default. Done means a Theme with exported fields such as Color and Logo can be used without a reflection panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100