File tree 5 files changed +56
-0
lines changed
5 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ <div >body</div >
Original file line number Diff line number Diff line change
1
+ <div >footer</div >
Original file line number Diff line number Diff line change
1
+
2
+ <div >
3
+ <% - include (' ./layout.ejs' , {
4
+ body: include (' ./body.ejs' ),
5
+ footer: include (' ./footer.ejs' )
6
+ })%>
7
+ </div >
8
+
9
+ <hr >
10
+
11
+ <div >
12
+ <% - include (' ./layout.ejs' , {
13
+ footer: include (' ./footer.ejs' )
14
+ })%>
15
+ </div >
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Advanced use of "include", fast layout, and dynamic rendering components.
3
+ */
4
+
5
+ var ejs = require ( '../../lib/ejs' ) ;
6
+ var read = require ( 'fs' ) . readFileSync ;
7
+ var join = require ( 'path' ) . join ;
8
+ var path = join ( __dirname , '/index.ejs' ) ;
9
+
10
+ var ret = ejs . compile ( read ( path , 'utf8' ) , { filename : path } ) ( { title : 'use slot' } ) ;
11
+
12
+ console . log ( ret ) ;
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html lang =" en" >
3
+
4
+ <head >
5
+ <meta charset =" UTF-8" >
6
+ <meta name =" viewport" content =" width=device-width, initial-scale=1.0" >
7
+ <title >layout</title >
8
+ </head >
9
+
10
+ <body >
11
+ <div >
12
+ <h2 ><%= title%> </h2 >
13
+
14
+ <% if (typeof body !== ' undefined' ) { % >
15
+ < %- body % >
16
+ < % } else { % >
17
+ < p> This is the default body content.< / p>
18
+ < % } %>
19
+
20
+ <div >description</div >
21
+
22
+ <% - footer %>
23
+ </div >
24
+
25
+ </body >
26
+
27
+ </html >
You can’t perform that action at this time.
0 commit comments