1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00
icebergs/core/code/json.go
2024-09-18 13:32:50 +08:00

38 lines
886 B
Go

package code
import (
"path"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
kit "shylinux.com/x/toolkits"
)
const (
DEMO_JSON = "demo.json"
)
const JSON = "json"
func init() {
Index.MergeCommands(ice.Commands{
JSON: {Actions: ice.MergeActions(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
m.FieldsSetDetail()
kit.For(kit.KeyValue(nil, "", kit.UnMarshal(m.Cmdx(nfs.CAT, path.Join(arg[2], arg[1])))), func(key, value string) {
m.Push(key, value)
})
}},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
ctx.DisplayStoryJSON(m)
}},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
m.Echo(kit.Format(nfs.Template(m, DEMO_JSON)))
}},
}, PlugAction())},
})
}