最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - sails.js get environment value from config in view - Stack Overflow

programmeradmin3浏览0评论

I use Sails.js with default template engine (EJS). I have a view defined directly from routes config:

config/routes.js

'/': {
    view: 'homepage'
 }

Is there a way to access environment in homepage.ejs? I need something like this:

views/homepage.ejs(next does not work, so I need a working solution)

...
<span>Hello you are on <%= sails.env %> environment</span>
...

to be rendered as:

Hello you are on production environment

Please do not suggest me to create controller for this.

I hope there is the way to get it either directly from view or through a locals in route, but how, that is the question.

I use Sails.js with default template engine (EJS). I have a view defined directly from routes config:

config/routes.js

'/': {
    view: 'homepage'
 }

Is there a way to access environment in homepage.ejs? I need something like this:

views/homepage.ejs(next does not work, so I need a working solution)

...
<span>Hello you are on <%= sails.env %> environment</span>
...

to be rendered as:

Hello you are on production environment

Please do not suggest me to create controller for this.

I hope there is the way to get it either directly from view or through a locals in route, but how, that is the question.

Share Improve this question edited Apr 21, 2015 at 8:56 Alexander Art asked Apr 21, 2015 at 8:08 Alexander ArtAlexander Art 1,5892 gold badges24 silver badges51 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

try this

<%= sails.config.environment %>
发布评论

评论列表(0)

  1. 暂无评论