问题描述
是否可以将sails.js应用程序配置为使用 .html
扩展而不是 .ejs
(但仍使用 ejs视图引擎
)?
Is it possible to configure sails.js apps to use .html
extentions rather than .ejs
(but still use the ejs view engine
)?
启动新应用
创建 ./views/home/index.ejs
和 ./views/layout.ejs
.
我想将扩展名更改为 .html
,但保持其他所有功能相同.
I'd like to change the extensions to .html
but keep everything else working the same way.
ie:我现在将具有 ./views/home/index.html
和 ./views/layout.html
,并且仍将主页注入布局页面,照常.
ie: I would now have ./views/home/index.html
and ./views/layout.html
, and the home page would still be injected into the layout page, as per normal.
请问如何配置?
推荐答案
在您的 config/views.js
中:
engine: {
ext: 'html',
fn: require('ejs').renderFile
},
似乎不能保证将来会支持此功能,因为他们从文档中删除了此功能,请谨慎使用.
Seems though that the future support for this feature is not guaranteed, since they removed this from docs, so use with caution.
这篇关于更改sails.js EJS视图以使用.html扩展名而不是.ejs扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!