1

Can please someone let me know how to render all the views in the server and send it to the web browser ? Just like any other PHP framework would do ?

Is this feasible at all ?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985

2 Answers2

1

Read through the Sails.js documentation.

In the controllers section you can learn about the Response Object. On the response object you have a function called view().

So you can use res.view() to render a view and send it to the client. Typical example:

functionNameHere: function(req, res, next) {
    res.view({
        data: {first: "one", second: "two"}
    });
}

Sails.js is built on top of Express.js. There are already plenty of tutorials on how to use Express on the internet.

Here is the documentation for Express.

sgress454
  • 24,870
  • 4
  • 74
  • 92
aludvigsen
  • 5,893
  • 3
  • 26
  • 37
0

Just put:

YourFunctionName : function (req,res) {
    res.view('yourview', option, data);
}

The parameters are optional depending on the way you need and you put your route.js file.

Read the controllers section on: http://sailsjs.org/#!documentation/controllers

Leonan Luppi
  • 138
  • 1
  • 10