Make a stupid page with a layout template

This commit is contained in:
Brandon Dyck 2024-07-10 16:36:24 -06:00
parent 38e9df8251
commit 6994df13a4
3 changed files with 20 additions and 4 deletions

View File

@ -1,4 +1,4 @@
-- LaunchBrowser()
LaunchBrowser()
local migrate = require "migrate"
@ -10,10 +10,9 @@ db:exec("PRAGMA foreign_keys")
migrate.migrate(db)
fm = require "fullmoon"
fm.setTemplate("hello", "Hello, {%& name %}")
fm.setTemplate({"/tmpl/", tmpl = "fmt"})
fm.setRoute("/hello/:name", function(r)
return fm.serveContent("hello", {name = r.params.name})
end)
fm.setTemplate("itworks", "<h1>It works!</h1>")
fm.setRoute("/", fm.serveContent("itworks"))
fm.setRoute("/", fm.serveContent("opendb"))
fm.run()

13
assets/tmpl/layout.tmpl Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Everything is Peachy</title>
</head>
<body>
{% function block.pagebody() %}
<h1>It works!</h1>
<p>But something seems to be missing…</p>
{% end %}
{% block.pagebody() %}
</body>
</html>

4
assets/tmpl/opendb.tmpl Normal file
View File

@ -0,0 +1,4 @@
{% function block.pagebody() %}
<p>Please select a database file to load.</p>
{% end %}
{% render('layout') %}