I need to assign a value to a variable in some method as beforeRender, as I do? (Sails.js v0.11.0)
Example CakePHP:
public function beforeRender(){
...
}
Example Rails:
before_render : ....
You can set locals in many places. It depends on your use case.
If the variable is different for each action, then you can place it inside the action calling the view.
If the variable is different for each request, then you can place it in a policy to set locals.
If the variable is static for a single route, you can put it in your routes.
If the variable is static for an application, then you can place in many places.
You can use Locals or Globals in your rendered view, which means any services you creates (even static objects) can be used inside your renderedViews
http://sailsjs.org/#!/documentation/concepts/Views/Locals.html http://sailsjs.org/#!/documentation/concepts/Globals