Skip to content

Commit

Permalink
component support minify
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed Sep 23, 2023
1 parent 9bf448f commit 24099b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type App struct {
serveHandler http.Handler

template map[string]*tmpl
component map[string]*template.Template
component map[string]*tmpl
templateFuncs []template.FuncMap

ETag bool
Expand Down
14 changes: 10 additions & 4 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (app *App) Template() *Template {
app.template = make(map[string]*tmpl)
}
if app.component == nil {
app.component = make(map[string]*template.Template)
app.component = make(map[string]*tmpl)
}
return &Template{
list: app.template,
Expand Down Expand Up @@ -89,7 +89,7 @@ type Template struct {
leftDelim string
rightDelim string
funcs []template.FuncMap
components map[string]*template.Template
components map[string]*tmpl
minifier *minify.M
parsed bool
}
Expand Down Expand Up @@ -292,7 +292,10 @@ func (tp *Template) newComponent(name string, parser func(t *template.Template)
panicf("nil component")
}

tp.components[name] = t
tp.components[name] = &tmpl{
Template: t,
m: tp.minifier,
}
tp.parsed = true
}

Expand Down Expand Up @@ -355,7 +358,10 @@ func (tp *Template) Component(ts ...*template.Template) *Template {
panicf("component '%s' already exists", name)
}

tp.components[name] = t
tp.components[name] = &tmpl{
Template: t,
m: tp.minifier,
}
}

return tp
Expand Down

0 comments on commit 24099b1

Please sign in to comment.