incorporated templates into demo

This commit is contained in:
overflowerror 2022-01-09 20:27:49 +01:00
parent 43fe094fac
commit 0575c9c692
2 changed files with 21 additions and 2 deletions

10
demo.sh
View file

@ -3,17 +3,23 @@
. base.sh
. mysql.sh
. credentials.sh
. shinden/engine.sh
connect "$mysqlHost" "$mysqlUser" "$mysqlPassword" "$mysqlDB"
route GET / index
index() {
header "Content-Type" "text/html"
endHeaders
echo "Users:"
echo "SELECT * FROM users" | query | getColumns 2
title="Test"
users=($(echo "SELECT * FROM users" | query | getColumns 2))
template "templates/demo.html.templ" ""
}
route GET /debug debug
debug() {
endHeaders

13
templates/demo.html.templ Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ print "$title" }}</title>
</head>
<body>
<ul>
{{ for user in "${users[@]}"; do }}
<li>{{ print "$user" }}</li>
{{ done }}
</ul>
</body>
</html>