帕格文檔說,如果具有以下格式,所有參數將被替換爲值:#{parameter_name}
這對我不起作用。Pug不會替換參數值
我的代碼:
//Template
doctype html
html(lang="en")
head
title= title
body
h1
Task is #{task_id}
p
task is #{task_id}
company is #{company_id}
//javascript
var express = require('express')
var app = express()
const util = require('util');
app.set('view engine', 'pug')
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.locals.pretty = true
app.get('/task/:company_id/:task_id',function(req,res) {
res.render('task',{task_id: req.query.task_id,company_id: req.query.company_id});
});
app.listen(8080, function() {
console.log('Example app listening on port !')
})
和輸出:
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<h1>
<Task>is </Task>
</h1>
<p>
<task>is </task>
<company>is </company>
</p>
</body>
</html>
沒有變量被解釋!這裏有什麼問題?我正在關注文檔! (我使用的最新版本,安裝了昨天)
我感覺像那些2名工程師:https://webapplog.com/jade/ – Nulik
我知道這不是問題。你確定要使用帕格嗎?它使用HAML,我沒有看到你正確使用它,它是空白敏感的。我建議使用HTML https://mozilla.github.io/nunjucks/ –
的nunjucks我真的不在乎我將使用什麼引擎。 nunjucks更好嗎? – Nulik