3
我有一個html文件footer.html
,它存儲了網站的頁腳,我想在不同的頁面上重複使用它。我如何使用lodash /下劃線將它包含在模板文件template.html
中?我已閱讀本article約node-partial
,但我不知道怎麼模塊node-partial
可以在快遞4.在express.js和lodash /下劃線的模板文件中包含頁腳?
var express = require('express')
, app = express()
, http = require('http').createServer(app)
, _ = require('lodash')._
,cons = require('consolidate');
app.engine('html', cons.lodash);
app.set('view engine', 'html')
app.set('views', './views')
app.get('/', function(req, res){
res.render('index.html', {hello: 'Welcome !'})
});
Template file
<h1><%= hello %></h1>
<p><%= _('hello') %></p>
<% include './footer.html' %> // Can I add a footer file to the template?
鏈接現在HTTP ://jade-lang.com/ –