primeira versão do e-li-nps construido com IA
This commit is contained in:
commit
06950d6e2c
34 changed files with 2524 additions and 0 deletions
43
internal/elinps/templates.go
Normal file
43
internal/elinps/templates.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package elinps
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func mustParseTemplates() *template.Template {
|
||||
// Local filesystem parsing (keeps the repo simple).
|
||||
// If you want a single-binary deploy, we can switch to go:embed by moving
|
||||
// templates into internal/elinps and embedding without "..".
|
||||
funcs := template.FuncMap{
|
||||
"seq": func(start, end int) []int {
|
||||
if end < start {
|
||||
return []int{}
|
||||
}
|
||||
out := make([]int, 0, end-start+1)
|
||||
for i := start; i <= end; i++ {
|
||||
out = append(out, i)
|
||||
}
|
||||
return out
|
||||
},
|
||||
"noteEq": func(ptr *int, v int) bool {
|
||||
return ptr != nil && *ptr == v
|
||||
},
|
||||
"produtoLabel": func(produto string) string {
|
||||
// Best-effort label from normalized produto.
|
||||
p := strings.ReplaceAll(produto, "_", " ")
|
||||
parts := strings.Fields(p)
|
||||
for i := range parts {
|
||||
if len(parts[i]) == 0 {
|
||||
continue
|
||||
}
|
||||
parts[i] = strings.ToUpper(parts[i][:1]) + parts[i][1:]
|
||||
}
|
||||
return strings.Join(parts, " ")
|
||||
},
|
||||
}
|
||||
|
||||
pattern := filepath.ToSlash("web/templates/*.html")
|
||||
return template.Must(template.New("").Funcs(funcs).ParseGlob(pattern))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue