Add view engine unit - handlebars - and response helpers
This commit is contained in:
11
app/http/controllers/Home.controller.ts
Normal file
11
app/http/controllers/Home.controller.ts
Normal 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 })
|
||||
}
|
||||
|
||||
}
|
||||
9
app/http/routes/home.routes.ts
Normal file
9
app/http/routes/home.routes.ts
Normal 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
1
app/http/views/home.hbs
Normal file
@@ -0,0 +1 @@
|
||||
<h1>Welcome to Daton!</h1>
|
||||
0
app/http/views/layouts/.gitkeep
Normal file
0
app/http/views/layouts/.gitkeep
Normal file
14
app/http/views/layouts/main.hbs
Normal file
14
app/http/views/layouts/main.hbs
Normal 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>
|
||||
0
app/http/views/partials/.gitkeep
Normal file
0
app/http/views/partials/.gitkeep
Normal file
Reference in New Issue
Block a user