Support deno 1.3.x/0.67.0; replace handlebars with view_engine library
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
export * from '../../lib/src/module.ts'
|
||||
export * from '../../di/module.ts'
|
||||
export * from '../../di/module.ts'
|
||||
|
||||
import * as std from '../../lib/src/external/std.ts'
|
||||
export { std }
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
import { env } from '../../lib/src/unit/Scaffolding.ts';
|
||||
import { env } from '../../lib/src/unit/Scaffolding.ts'
|
||||
import {ViewEngine} from '../../lib/src/const/view_engines.ts'
|
||||
|
||||
export default {
|
||||
name: env('APP_NAME', 'Daton'),
|
||||
|
||||
views: {
|
||||
/*
|
||||
* View engine that should be used to render templates.
|
||||
* Options are Handlebars, Ejs, or Denjuck.
|
||||
*/
|
||||
engine: ViewEngine.Handlebars,
|
||||
|
||||
/*
|
||||
* Relative path from the app directory to the base directory where
|
||||
* view files should be looked up.
|
||||
*/
|
||||
base_dir: 'http/views',
|
||||
|
||||
/*
|
||||
* If using Handlebars, optionally, the path to the directory within the
|
||||
* base_dir that contains the partials. They will be automatically registered
|
||||
* with Handlebars.
|
||||
*/
|
||||
partials_dir: 'partials',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
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'
|
||||
import {Injectable} from '../../../di/module.ts'
|
||||
|
||||
@Injectable()
|
||||
export default class HomeController extends Controller {
|
||||
|
||||
get_home(request: Request) {
|
||||
return view('home', { request })
|
||||
async get_home(request: Request) {
|
||||
return view('home', { greeting: 'Hello' })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
<h1>Welcome to Daton!</h1>
|
||||
<html>
|
||||
{{> header }}
|
||||
<body>
|
||||
<h1>{{ greeting }} from Daton!</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +0,0 @@
|
||||
<!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>
|
||||
3
app/http/views/partials/header.hbs
Normal file
3
app/http/views/partials/header.hbs
Normal file
@@ -0,0 +1,3 @@
|
||||
<head>
|
||||
<title>Daton</title>
|
||||
</head>
|
||||
@@ -8,8 +8,11 @@ import units from './units.ts'
|
||||
* Let's get up and running. The scaffolding provides the bare minimum
|
||||
* amount of support required to get Daton up and running. The app handles
|
||||
* the rest.
|
||||
*
|
||||
* Daton will automatically load and process application resources, which is
|
||||
* why we need to pass in the base path of this script.
|
||||
*/
|
||||
const scaffolding = make(Scaffolding)
|
||||
const scaffolding = make(Scaffolding, import.meta.url)
|
||||
await scaffolding.up()
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,11 +17,11 @@ export default [
|
||||
ConfigUnit,
|
||||
DatabaseUnit,
|
||||
ModelsUnit,
|
||||
ViewEngineUnit,
|
||||
HttpKernelUnit,
|
||||
MiddlewareUnit,
|
||||
ControllerUnit,
|
||||
ViewEngineUnit,
|
||||
RoutesUnit,
|
||||
RoutingUnit,
|
||||
// HttpServerUnit,
|
||||
HttpServerUnit,
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user