package models_pages import ( "bytes" "html/template" "time" ) const ( // Имя соответствующего шаблона MainPageTmplName = "main.gohtml" MainPageTmplNameAjax = "main_ajax.gohtml" ) func RenderMainPage(templates *template.Template, version int64, ajax bool) ([]byte, error) { var pageData bytes.Buffer context := map[string]any{ "version": version, "renderingTimestamp": time.Now().Unix(), } templateName := MainPageTmplName if ajax { templateName = MainPageTmplNameAjax } if err := templates.ExecuteTemplate(&pageData, templateName, context); err != nil { return nil, err } return pageData.Bytes(), nil }