1
0
forked from x/icebergs
icebergs/core/code/html.go
2023-04-23 12:06:58 +08:00

32 lines
1.0 KiB
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"
)
func require(arg ...string) string { return path.Join(nfs.PS, ice.REQUIRE, path.Join(arg...)) }
const HTML = "html"
func init() {
Index.MergeCommands(ice.Commands{
HTML: {Name: "html path auto", Help: "网页", Actions: ice.MergeActions(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
m.EchoIFrame(kit.MergeURL(require(arg[2], arg[1]), "_v", kit.Hashs(mdb.UNIQ)))
}},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
m.EchoIFrame(kit.MergeURL(require(arg[2], arg[1]), "_v", kit.Hashs(mdb.UNIQ)))
}},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
m.Echo(kit.Renders(nfs.TemplateText(m, "demo.html"), ice.Maps{ice.LIST: kit.Format(kit.List(kit.Dict(ctx.INDEX, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))))})).RenderResult()
}},
}, PlugAction())},
})
}