EJS (일반적으로 비취 사용)를 사용하여 첫 번째 앱을 설치하려고하는데 모든 설정과 페이지가로드되어 있는데 어떻게해야하는지에 대한 자습서를 따랐습니다. '이것은 내 레이아웃Node.js에서 EJS를 사용하려고 시도합니다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf8">
<title>
<%= title %>
</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<%- body %>
</body>
</html>
이며,이 내 홈 페이지
<div class='title'>
<%= title %>
</div>
입니다하지만 홈 페이지 및 페이지 소스보기를로드 할 때, 내가 볼 모두 홈 페이지 요소, 나는 돈이다 t 그 html, body, head, title
그 물건을 참조하십시오. 확실하지 왜이 내 app.js
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
및 제 2 개 파일은 사전에 layout.ejs, index.ejs
덕분입니다!
다음은 익스프레스 (3.X)의 http://robdodson.me/blog/2012/05/31/how-to-use-ejs-in-express/
이 줄은 이미 파일에 있습니다. – slecorne