Reputation: 39
Perhaps i want to store my views in /pages directory. Next code in configs of sails directory does not reinit views path:
paths: {
views: path.normalize(__dirname + '/../pages')
}
but code for public dir works well:
paths: {
public: path.normalize(__dirname + '/../any_public_dir')
}
What can i do?
Upvotes: 3
Views: 2361
Reputation: 541
If you do not use sails lift
, but rather have your own app and lift from inside it:
var Sails = require('sails');
Sails.lift({}, function(err, server) {});
then you can specify the path there
var Sails = require('sails');
Sails.lift({
//environment: 'test', // if you need to set
//hooks:{foo: false}, // if you want to disable some of them
paths: { views: 'mydir/views' }, // relative to appDir
}, function(err, server) {});
You can later (in the sails controllers/services) get the current views dir:
var vdir = sails.config.paths.views;
To get other configurable pathes console.log(Object.keys(sails.config));
Upvotes: 0
Reputation: 24948
Because of the way that Sails loads configuration, it's not currently possible to change the path for most things from within a file in the config
folder. You can, however, do it in the .sailsrc
file:
{
"paths": {
"views": "../pages"
}
}
Upvotes: 5