-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from Jeffrey-mu/main
Include advanced usage examples
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>body</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>footer</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
<div> | ||
<%-include('./layout.ejs', { | ||
body: include('./body.ejs'), | ||
footer: include('./footer.ejs') | ||
})%> | ||
</div> | ||
|
||
<hr> | ||
|
||
<div> | ||
<%-include('./layout.ejs', { | ||
footer: include('./footer.ejs') | ||
})%> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Advanced use of "include", fast layout, and dynamic rendering components. | ||
*/ | ||
|
||
var ejs = require('../../lib/ejs'); | ||
var read = require('fs').readFileSync; | ||
var join = require('path').join; | ||
var path = join(__dirname, '/index.ejs'); | ||
|
||
var ret = ejs.compile(read(path, 'utf8'), {filename: path})({title: 'use slot'}); | ||
|
||
console.log(ret); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>layout</title> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<h2><%=title%></h2> | ||
|
||
<% if (typeof body !== 'undefined') { %> | ||
<%- body %> | ||
<% } else { %> | ||
<p>This is the default body content.</p> | ||
<% } %> | ||
|
||
<div>description</div> | ||
|
||
<%- footer %> | ||
</div> | ||
|
||
</body> | ||
|
||
</html> |