我正在尝试使用jade。我正在尝试在get请求中呈现模板,我的代码是
app.get('/promocode/generate-promocode',mw.authenticate,function(req,res)
{ res.render('index1', {});
});
我的layout.jade文件代码是
doctype 5
html
head
block head
title= title
include layout/css
include layout/headerjs
body
include header/main
include layout/topbar
.middle-content
.container
.wrapper
block content
include footer/main
include layout/footerjs
我的index.jade文件代码是
extends layout
h1 Welcome to Marketplace
h1 Welcome to Marketplace
h1 Welcome to Marketplace
h1 Welcome to Marketplace
h1 Welcome to Marketplace
h1 Welcome to Marketplace
当我转到页面时,它只显示layout.jade语法,没有h1标题,内容为“欢迎使用市场”。任何建议如何在html页面中显示此标题标签??
答案 0 :(得分:1)
您必须在index.jade中定义必须继承的相同块。
extends layout
block content
h1 Welcome to Marketplace
考虑到您提供的res.render('index1', {});
和index.jade
中的文件名不匹配,这可以解决您的问题。