Last active
September 22, 2016 09:50
-
-
Save jinlong/8297190 to your computer and use it in GitHub Desktop.
Express blog demo.
This file contains hidden or 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
<h1>{{blog.title}}</h1> | |
Published: {{blog.published}} | |
<p/> | |
{{blog.body}} |
This file contains hidden or 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
<h1>Blog!</h1> | |
{{#each entries}} | |
<p> | |
<a href="/article/{{id}}">{{title}}</a><br/> | |
Published: {{published}} | |
</p> | |
{{/each}} |
This file contains hidden or 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
<html> | |
<head> | |
<title>Home Page</title> | |
</head> | |
<body> | |
<h1>Blog!</h1> | |
<footer> | |
<p> | |
<a href="/">Home</a> ~ <a href="/about">About Me</a> ~ <a href="/article">Some Article</a> | |
</p> | |
</footer> | |
</body> | |
</html> |
This file contains hidden or 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
<html> | |
<head> | |
<title>{{title}}</title> | |
</head> | |
<body> | |
{{{body}}} | |
<footer> | |
<p> | |
<a href="/">Home</a> ~ <a href="/about">About Me</a> | |
</p> | |
</footer> | |
</body> | |
</html> |
This file contains hidden or 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
<link href="/bootstrap/css/bootstrap.css" rel="stylesheet"> |
layout.html 是html 通用的文件模板,其它的 html 可能就 {{title}} 和 {{{body}}} 发生变化,不同的 title 和 body 在res.render 的时候传入:
例如:res.render('index',{title:"My Blog", entries:blogEngine.getBlogEntries()});
article.html 和 home.html 都会套用 layout.html 模板
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
有些疑问
{{{body}}}
是怎么自动从home-tpl.html引入内容过来。<head>
<footer>
等partial。求指教~~