Add view engine unit - handlebars - and response helpers

This commit is contained in:
garrettmills
2020-08-07 09:51:25 -05:00
parent 3e4f8f00f2
commit b5bde7d077
14 changed files with 165 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
import Controller from '../../../lib/src/http/Controller.ts'
import {Request} from '../../../lib/src/http/Request.ts'
import {view} from '../../../lib/src/http/response/helpers.ts'
export default class HomeController extends Controller {
get_home(request: Request) {
return view('home', { request })
}
}

View File

@@ -0,0 +1,9 @@
import { RouterDefinition } from '../../../lib/src/http/type/RouterDefinition.ts'
export default {
prefix: '/',
middleware: [],
get: {
'/': 'controller::Home.get_home',
},
} as RouterDefinition

1
app/http/views/home.hbs Normal file
View File

@@ -0,0 +1 @@
<h1>Welcome to Daton!</h1>

View File

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
{{#if title}}
<title>{{ title }} | Daton</title>
{{else}}
<title>Daton</title>
{{/if}}
</head>
<body>
{{{ body }}}
</body>
</html>

View File