在Express中使用`jade`模板引擎时渲染`html` [英] Rendering `html` when using `jade` templating engine, in Express
问题描述
如何在将模板引擎保持为jade
的同时呈现html
文件?
How do you render an html
file while keeping the templating engine as jade
?
app.set('view engine', 'jade');
是我将模板引擎设置为jade
的位置,我想做类似
app.set('view engine', 'jade');
is where i've set the templating engine as jade
and I want to do something like
app.get('/world', function(req,res){
res.render('profile.html', );
渲染html
文件.
我正在使用express.js在node.js中进行编程.
I'm programming in node.js using express.js.
注意:我已经使用var html=require('html');
我知道res.render
不必使用,因为html
已经渲染. res.send(profile.html);
给出profile is undefined
I understand res.render
need not be used as html
is already rendered. res.send(profile.html);
gives error of profile is undefined
推荐答案
您可以渲染玉文件(.jade),但不能渲染html文件,因为结果将是html.呈现html文件是什么意思?
You can render jade files (.jade) but not html files as the result will be the html. What do you mean by rendering the html file?
将res.render('profile.html')
替换为res.sendfile('[path_to_the_file]profile.html')
这篇关于在Express中使用`jade`模板引擎时渲染`html`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!