在express.js node.js中渲染复杂的html

时间:2014-09-10 21:17:37

标签: javascript node.js express

我使用node.js 0.10.12和express.js 4.2.0

我想设置app.engine来渲染复杂的html文件,包含javascript和/或php函数的文件。

我尝试了Drew Noakes的答案here,但没有。 在我的情况下,我有

app.set('views', './views');
app.engine('html', require('jade').renderFile);

app.get('/', function(req, res) {
res.render('qs.html');
});

当我访问该页面时,我得到了

SyntaxError: views\qs.html:27 25| <p>the hash has to be always to the end of the url, to be well-defined.<br> 26| sometimes when i click to add the hash first and then the query string, the page does not reload and the query string is added after the hash, wich are both wrong</p>
> 27| =============================<br> 28| <button name="hey1" onClick="historytestindex();">history test index</button> 29| <button name="hey2" onClick="historytestajaxtwo();">history test ajaxtwo</button> 30| <button name="hey3" onClick="historytestajaxfour();">history test ajaxfour</button> Unexpected token === at Function (<anonymous>) at assertExpression (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\lexer.js:30:3) at Object.Lexer.code (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\lexer.js:570:23) at Object.Lexer.next (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\lexer.js:864:15) at Object.Lexer.lookahead (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\lexer.js:113:46) at Parser.lookahead (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\parser.js:100:23) at Parser.peek (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\parser.js:77:17) at Parser.tag (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\parser.js:791:30) at Parser.parseTag (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\parser.js:719:17) at Parser.parseExpr (C:\Program Files (x86)\nodejs\secondtest\node_modules\jade\lib\parser.js:188:21)

我猜它会发现语法错误,但我不知道为什么,因为我将html与jade配对。

请,有一种方法可以使用node + express渲染复杂的html + js + php文件。

由于

0 个答案:

没有答案
相关问题