diff --git a/core.go b/core.go index 3c80602..967eaca 100644 --- a/core.go +++ b/core.go @@ -104,7 +104,7 @@ func (app *App) Run(router *httprouter.Router) { // check if template engine is enable TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE") - if TemplateEnableStr == "" { + if "" == TemplateEnableStr { TemplateEnableStr = "false" } TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr) @@ -119,7 +119,7 @@ func (app *App) Run(router *httprouter.Router) { } useHttps, _ := strconv.ParseBool(useHttpsStr) - if runMode == "dev" { + if "dev" == runMode { fmt.Printf("Welcome to Goffee\n") if useHttps { fmt.Printf("Listening on https \nWaiting for requests...\n") diff --git a/response.go b/response.go index 46f31ee..d6202c7 100644 --- a/response.go +++ b/response.go @@ -40,6 +40,16 @@ func (rs *Response) BufferFile(name string, filetype string, b bytes.Buffer) *Re return rs } +// writes the contents of a buffer to the HTTP response with specified file name and type if not terminated. +func (rs *Response) BufferInline(name string, filetype string, b bytes.Buffer) *Response { + + if rs.isTerminated == false { + rs.HttpResponseWriter.Header().Add("Content-Type", filetype) + b.WriteTo(rs.HttpResponseWriter) + } + return rs +} + // sets the response's content type to HTML and assigns the provided body as the response body if not terminated. func (rs *Response) Any(body any) *Response { if rs.isTerminated == false { diff --git a/template/components/content_table.go b/template/components/content_table.go index 9e77908..5c6a21b 100644 --- a/template/components/content_table.go +++ b/template/components/content_table.go @@ -15,6 +15,7 @@ type ContentTableTH struct { } type ContentTableTD struct { - ID string - Value interface{} // string or component struct according ValueType + ID string + Value interface{} // string or component struct according ValueType + ValueClass string } diff --git a/template/components/content_table.html b/template/components/content_table.html index e5aaf50..36f9b8b 100644 --- a/template/components/content_table.html +++ b/template/components/content_table.html @@ -7,7 +7,7 @@
{{- range .AllTD}}