FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
javascript-tutorial-server/modules/render.js at master · AADOT/javascript-tutorial-server · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AADOT
/
javascript-tutorial-server
Public
forked from
javascript-tutorial/server
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
javascript-tutorial-server
/
modules
/
render.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (20 loc) · 781 Bytes
Breadcrumbs
javascript-tutorial-server
/
modules
/
render.js
Copy path
File metadata and controls
24 lines (20 loc) · 781 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let
Renderer
=
require
(
'jsengine/koa/renderer'
)
;
// (!) this.render does not assign this.body to the result
// that's because render can be used for different purposes, e.g to send emails
exports
.
init
=
function
(
app
)
{
app
.
use
(
async
function
(
ctx
,
next
)
{
let
renderer
=
new
Renderer
(
ctx
)
;
/**
* Render template
* Find the file:
* if locals.useAbsoluteTemplatePath => use templatePath
* else if templatePath starts with / => lookup in locals.basedir
* otherwise => lookup in ctx.templateDir (MW should set it)
*
@param
templatePath file to find (see the logic above)
*
@param
locals
*
@returns
{
String
}
*/
ctx
.
render
=
(
templatePath
,
locals
)
=>
renderer
.
render
(
templatePath
,
locals
)
;
await
next
(
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL