pre.xgo 506 B

123456789101112131415161718192021222324252627282930313233343536
  1. paths := import("paths")
  2. html := import("html").Renderer()
  3. htmExt := func(c){
  4. if c.is_compo {
  5. return
  6. }
  7. c.pp.print(`<!doctype html><html>`)
  8. c.pp.print(html.head().body(
  9. func(){
  10. if c.title {
  11. return html.title().body(c.title)
  12. }
  13. }(),
  14. html.script({
  15. src: `https://unpkg.com/htmx.org@1.9.2`
  16. })
  17. ))
  18. c.pp.print(`<body>`)
  19. c.pp.print(html.div().body(c.global.val))
  20. }
  21. exts := {
  22. ".htm": htmExt,
  23. ".html": htmExt
  24. }
  25. export func(c){
  26. ext := c.fext
  27. cl := exts[ext]
  28. if cl {
  29. cl(c)
  30. }
  31. }