41 lines
574 B
Text
41 lines
574 B
Text
|
fmt := import("fmt")
|
||
|
paths := import("paths")
|
||
|
html := import("html").new_render()
|
||
|
|
||
|
htmExt := func(c){
|
||
|
if c.is_compo {
|
||
|
return
|
||
|
}
|
||
|
c.pp.print(`<!doctype html><html>`)
|
||
|
|
||
|
c.pp.print(html.head().body(
|
||
|
func(){
|
||
|
if c.title {
|
||
|
return html.title().body(c.title)
|
||
|
}
|
||
|
}(),
|
||
|
html.script({
|
||
|
src: `https://unpkg.com/htmx.org@1.9.2`
|
||
|
})
|
||
|
))
|
||
|
|
||
|
c.pp.print(`<body>`)
|
||
|
}
|
||
|
|
||
|
exts := {
|
||
|
".htm": htmExt,
|
||
|
".html": htmExt
|
||
|
}
|
||
|
|
||
|
export func(c){
|
||
|
ext := paths.ext(c.pp.filepath)
|
||
|
ext = paths.ext(
|
||
|
c.pp.filepath[:len(c.pp.filepath) - len(ext)]
|
||
|
)
|
||
|
|
||
|
cl := exts[ext]
|
||
|
if cl {
|
||
|
cl(c)
|
||
|
}
|
||
|
}
|