如何在express.js中包含我的html / js / css文件? 有什么方法可以管理模板吗?
我想只使用HTML(没有玉)。
<head>
<DATA>
</head>
<header>
<?php include('includes/header.html'); ?>
</header>
<topnavigation>
<?php include('top_navigation/header.html'); ?>
</topnavigation>
<content>
<?php include('website/header.html'); ?>
</content>
<footer>
<?php include('includes/content.html'); ?>
</footer>
答案 0 :(得分:0)
.ejs
模板引擎,但您只需将.ejs
替换为.html
,之后只需更改一件事。
更改此行: -
// set the view engine to ejs
app.set('view engine', 'ejs');
用这个: -
app.engine('html', require('ejs').renderFile);
现在你可以使用普通html
页面作为模板引擎了