Skip to content

Commit

Permalink
Refactor placholder dir into common function
Browse files Browse the repository at this point in the history
  • Loading branch information
laenzlinger committed Mar 31, 2024
1 parent f46c6e8 commit 9c0557f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func Target() string {
return viper.GetString("target")
}

func PlaceholderDir() string {
return filepath.Join(Target(), "placeholder")
}

// returns configuration of source band.
func NewBand() Band {
band := Band{
Expand Down
2 changes: 1 addition & 1 deletion internal/html/template/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func CreateSetlist(data *Data) (string, error) {
}

func CreatePlaceholder(data *Data) (string, error) {
return createFromTemplate(data, placeholderTemplate, filepath.Join(config.Target(), "placeholder", "placeholder.html"))
return createFromTemplate(data, placeholderTemplate, filepath.Join(config.PlaceholderDir(), "placeholder.html"))
}

func createFromTemplate(data *Data, t *template.Template, filename string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/sheet/sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *Sheet) sourceFilePath() string {

func (s *Sheet) pdfDir() string {
if s.placeholder {
return filepath.Join(config.Target(), "placeholder")
return config.PlaceholderDir()
}
return s.sourceDir()
}
Expand Down

0 comments on commit 9c0557f

Please sign in to comment.