由于某些原因,我无法将变量传递给具有Node JS的帕格模板。节点JS将变量传递给Jade/Pug
app.get("/", function (req, res) {
res.render('index', { hello : 'Hey'})
})
....
extends layout.pug
block content
h1 #{hello} guy
这只是返回与“哈巴狗index.html文件中
由于某些原因,我无法将变量传递给具有Node JS的帕格模板。节点JS将变量传递给Jade/Pug
app.get("/", function (req, res) {
res.render('index', { hello : 'Hey'})
})
....
extends layout.pug
block content
h1 #{hello} guy
这只是返回与“哈巴狗index.html文件中
我认为你正在使用JADE编码(#{}你好) “家伙” “(更新玉)插件与静态.html - 完全错误。
按照以下线路:
使用这首
app.set('views', __dirname + '/public/views');
app.set('view engine', 'pug');
比这传递给第一次访问
app.get('/', function (req, res) {
res.render('index', { title: 'Hey', message: 'Hello there!'});
});
比在模板文件“index.pug呼应“in”/ public/views“
html
head
title= title
body
h1= message
它仍然没有工作,一切都是一样的。 –
给我你的目录结构的快照 + 显示我 app.set( '意见',__dirname + '/公/若干意见')的服务器上的文件; app.set('view engine','pug'); ('/',function(req,res){ res.render('index',{title:'Hey',message:'Hello there!'}); ( )通过这个来第一次访问 }); –
现在它只是说“快递”https://github.com/jpking72/nodejsfiddle.git –
你可以把更多的代码?什么是'应用程序'? 'layout.pug'有什么? – chharvey