an updated and hopefully faster version of the ST Toolbox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
766 B

package web
import (
"html/template"
"net/http"
)
func JobsHandler(w http.ResponseWriter, r *http.Request) {
jobs := []string{"Job 1", "Job 2", "Job 3"} // Replace with actual data fetching
if r.Header.Get("HX-Request") == "true" {
// This is an HTMX request, return the jobs content wrapped in the content template
tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/partials/jobs.html"))
tmpl.ExecuteTemplate(w, "content", map[string]interface{}{
"Title": "Jobs",
"Jobs": jobs,
})
} else {
// This is a full page request
tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/partials/jobs.html"))
tmpl.Execute(w, map[string]interface{}{
"Title": "Jobs",
"Jobs": jobs,
})
}
}