mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Clean up the css related template funcs package structure
Deprecate and move: * resources.ToCSS => css.SASS * resources.PostProcess => css.PostProcess * resources.Babel => js.Babel Updates #12618
This commit is contained in:
@@ -17,7 +17,9 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/tpl/css"
|
||||
"github.com/gohugoio/hugo/tpl/internal"
|
||||
"github.com/gohugoio/hugo/tpl/js"
|
||||
)
|
||||
|
||||
const name = "resources"
|
||||
@@ -33,6 +35,22 @@ func init() {
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(cctx context.Context, args ...any) (any, error) { return ctx, nil },
|
||||
OnCreated: func(m map[string]any) {
|
||||
for _, v := range m {
|
||||
switch v := v.(type) {
|
||||
case *css.Namespace:
|
||||
ctx.cssNs = v
|
||||
case *js.Namespace:
|
||||
ctx.jsNs = v
|
||||
}
|
||||
}
|
||||
if ctx.cssNs == nil {
|
||||
panic("css namespace not found")
|
||||
}
|
||||
if ctx.jsNs == nil {
|
||||
panic("js namespace not found")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Get,
|
||||
@@ -57,21 +75,6 @@ func init() {
|
||||
[][2]string{},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.ToCSS,
|
||||
[]string{"toCSS"},
|
||||
[][2]string{},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.PostCSS,
|
||||
[]string{"postCSS"},
|
||||
[][2]string{},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.Babel,
|
||||
[]string{"babel"},
|
||||
[][2]string{},
|
||||
)
|
||||
|
||||
return ns
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user