Skip to content

Commit

Permalink
remove IsCustomTemplate func
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed Nov 6, 2023
1 parent cdb4689 commit 3ebfb7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 7 additions & 3 deletions pkg/utils/template_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ const (

// TemplatePathURL returns the Path and URL for the provided template
func TemplatePathURL(fullPath, templateId string) (string, string) {
if IsCustomTemplate(fullPath) {
var templateDirectory string
configData := config.DefaultConfig
if configData.TemplatesDirectory != "" && strings.HasPrefix(fullPath, configData.TemplatesDirectory) {
templateDirectory = configData.TemplatesDirectory
} else {
return "", ""
}

relativePath := strings.TrimPrefix(strings.TrimPrefix(fullPath, config.DefaultConfig.TemplatesDirectory), "/")
finalPath := strings.TrimPrefix(strings.TrimPrefix(fullPath, templateDirectory), "/")
templateURL := TemplatesRepoURL + templateId
return relativePath, templateURL
return finalPath, templateURL
}
5 changes: 0 additions & 5 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,3 @@ func StringSliceContains(slice []string, item string) bool {
}
return false
}

// IsCustomTemplate checks if the template is a custom template
func IsCustomTemplate(templatePath string) bool {
return !strings.HasPrefix(templatePath, config.DefaultConfig.TemplatesDirectory)
}

0 comments on commit 3ebfb7a

Please sign in to comment.