Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sails.js get environment value from config in view

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.

like image 415
Alexander Arutinyants Avatar asked Apr 21 '15 08:04

Alexander Arutinyants


1 Answers

try this

<%= sails.config.environment %>
like image 145
Ryan Wu Avatar answered Sep 30 '22 11:09

Ryan Wu