[英]an error in pug(jade) not show content from layout
hi guys I'm recently start pug(jade) and i cant load my layout 嗨,大家好,我最近开始做哈巴狗(玉),我无法加载我的布局
here its my layout.pug 这是我的layout.pug
html(lang='en')
head
title hi
link(rel='stylesheet', type='text/css', href='../public/css/W3.css')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Allerta+Stencil')
body
div.w3-bar.w3-black
div.w3-left.w3-margin-left
a.w3-bar-item.w3-opacity.w3-large.w3-btn(href='#') My website template
a.w3-bar-item.w3-button.w3-hover-green(href='#') Home
a.w3-bar-item.w3-button.w3-hover-green(href='#') Link 1
div.w3-right.w3-margin-right
a.w3-bar-item.w3-button.w3-hover-blue(href='#') Link 2
a.w3-bar-item.w3-button.w3-hover-orange(href='#') Link
div.w3-margin.w3-continer.w3-center
div.w3-margin.w3-card-4.w3-continer
p.w3-jumbo.w3-opacity(class='.w3-allerta') this is my first template
p.w3-large.w3-margin welcome to Home
and i load it with index.pug 我用index.pug加载
extends layout
block content
h3 hello world
which i load that with this code 我用这段代码加载
app.get('/', function (req, res) {
res.render('index.pug');
});
also i put my css framework w3.css in public folder with this code 我也用此代码将css框架w3.css放在公用文件夹中
app.use(express.static(path.join(__dirname, "public")))
and i get this error 我得到这个错误
Error: C:\Users\MashadService.ir\Desktop\node js\express-simple-website\views\index.pug:3:1
Unexpected block content
at makeError (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-error\index.js:32:13)
at error (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-linker\index.js:7:30)
at C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-linker\index.js:47:9
at Array.forEach (<anonymous>)
at link (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug-linker\index.js:45:20)
at compileBody (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:170:9)
at Object.exports.compile (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:242:16)
at handleTemplateCache (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:215:25)
at Object.exports.renderFile (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:427:10)
at Object.exports.renderFile (C:\Users\MashadService.ir\Desktop\node js\express-simple-website\node_modules\pug\lib\index.js:417:21)
thank you for helping me 感谢你们对我的帮助
layout.pug in add code block content
在layout.pug中添加代码block content
html(lang='en')
head
title hi
link(rel='stylesheet', type='text/css', href='../public/css/W3.css')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Allerta+Stencil')
body
div.w3-bar.w3-black
div.w3-left.w3-margin-left
a.w3-bar-item.w3-opacity.w3-large.w3-btn(href='#') My website template
a.w3-bar-item.w3-button.w3-hover-green(href='#') Home
a.w3-bar-item.w3-button.w3-hover-green(href='#') Link 1
div.w3-right.w3-margin-right
a.w3-bar-item.w3-button.w3-hover-blue(href='#') Link 2
a.w3-bar-item.w3-button.w3-hover-orange(href='#') Link
div.w3-margin.w3-continer.w3-center
div.w3-margin.w3-card-4.w3-continer
p.w3-jumbo.w3-opacity(class='.w3-allerta') this is my first template
p.w3-large.w3-margin welcome to Home
block content
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.