我想用 HTML 编写 HTML。不是什么奇特的方式。唯一很酷的是能够使用某种 include
语句来包含每个页面的页眉/导航/页脚。
我看过哈巴狗、ejs、 mustache 、双节棍等等。我讨厌所有这些东西。我只是想写 HTML..
什么是简单的 Node 模块来做到这一点?如何在我的主 app.js
中设置渲染引擎?我正在使用 express
最佳答案
您只需设置快速路由即可连接 html
页面。这是一个简单的例子:
var express = require('express');
// Create express app
var app = express();
// Route index page to an index html page
app.get('/', function(req, res){
res.sendFile(__dirname + '/path/to/views/index.html');
});
// Create server
app.listen(8080, function(){
console.log('Ready on port 8080...');
});
顺便说一句,ejs
基本上是 html
,但具有一些额外的功能。您完全可以在 ejs
页面中只编写 html
,然后在熟悉了 ejs
功能后开始使用它。
关于javascript - Node 中的基本 html 引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36960280/