有没有办法在 Express + Node.js 中使用多个视图引擎 [英] Is there any way to use multiple view engines with Express + Node.js
问题描述
场景:我使用Node.js、Express + Handlebars 作为视图引擎和 MongoDB.
Scenario: I had developed some transactional pages using Node.js, Express + Handlebars as view engine and MongoDB.
现在的问题是在模块集成过程中我得到了一些建立在 Express + Jade 作为视图引擎.
Now the issue is during module integration I got some of the pages which are built on Express + Jade as view engine.
问题:如何集成建立在 Handlebars 上的页面 &一些翡翠?
Question: How to integrate pages built on Handlebars & some on Jade?
推荐答案
- 在您的 package.json 中添加两个引擎和 consolidate.js>
在 yourapp.js
- Add both engines and consolidate.js in your package.json
In yourapp.js
var engine = require('consolidate');
var engines = require('consolidate');
app.engine('jade',engines.jade);
app.engine('jade', engines.jade);
app.engine('handlebars',engine.handlebars);
app.engine('handlebars', engines.handlebars);
更多信息这里
这篇关于有没有办法在 Express + Node.js 中使用多个视图引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!