[MM-34798] Respect MM_SERVER_PATH when looking for templates (#17410)

Этот коммит содержится в:
Ben Schumacher
2021-04-21 20:35:57 +02:00
коммит произвёл GitHub
родитель a1a8f00957
Коммит f14b0097dd
3 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@@ -7,10 +7,12 @@ import (
"bytes"
"html/template"
"io"
"os"
"path/filepath"
"sync"
"github.com/fsnotify/fsnotify"
"github.com/mattermost/mattermost-server/v5/utils/fileutils"
)
// Container represents a set of templates that can be render
@@ -29,6 +31,15 @@ type Data struct {
HTML map[string]template.HTML
}
func GetTemplateDirectory() (string, bool) {
templatesDir := "templates"
if mattermostPath := os.Getenv("MM_SERVER_PATH"); mattermostPath != "" {
templatesDir = filepath.Join(mattermostPath, templatesDir)
}
return fileutils.FindDir(templatesDir)
}
// NewFromTemplates creates a new templates container using a
// `template.Template` object
func NewFromTemplate(templates *template.Template) *Container {