I've been struggling with this issue for hours and I can't find a solution to it, I can also not find a solution on internet, i've been reading over and over again the docs and I am doing it as displayed as I can tell, but it won't work.

I am trying to pass an array from the controller to the view and it's just not working, I get the error that the variable is undefined even if I use an if statement, and even if I use locals.errors (errors is my array sent from controller), it still won't display any data.

controller

```
/**
 * AuthControllerController
 *
 * @description :: Server-side actions for handling incoming requests.
 * @help        :: See https://sailsjs.com/docs/concepts/actions
 */

module.exports = {

    login: async function (req, res) {

    },

    signup: async function (req, res) {

        let username = req.param('username'),//regex condition should be added to model
            password = req.param('password'),
            confirmedpass = req.param('confirmedpass'),
            email = req.param('useremail');

        let errors = [];

        if (password !== confirmedpass) {
            errors.push('Passwords doesn\'t match');
        }

        if (!_.isString(username) || username.length > 20 || !username.match(/^[a-zA-Z0-9]+$/)) {
            errors.push('Username must not be longer as 20 characters, letters and numbers only');
        }

        if (await Account.findOne({username: username})) {
            errors.push('Username already exists');
        }

        if (await Account.findOne({email: email})) {
            errors.push('Email is already in use');
        }

        if (errors.length > 0) {
            console.log(`Errors ${errors}`);

            return res.view('pages/signup', {errors: errors, layout: 'layouts/blanklayout'});
        }

        try {
            await Account.create({username: username, password: password, email: email});
        }
        catch(e) {
            return console.log(e.message);
        }

        return console.log(`Username: ${username} | Password: ${password} | Email: ${email}`);
    },

    logout: async function (req, res) {

    },

    loadView: function (req, res) {

        return res.view('pages/signup', {layout: 'layouts/blanklayout'});

    }

};

```

and here is the view layout

```
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="/images/favicon.ico">

    <title>LC-RP - Dashboard</title>

    <link rel="stylesheet" href="/styles/vendors_css.css">
    <link rel="stylesheet" href="/styles/style.css">
    <link rel="stylesheet" href="/styles/skin_color.css">

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
</head>

<body class="hold-transition theme-primary bg-img" style="background:
radial-gradient(circle at 100% 50%, transparent 20%, rgba(255,255,255,.2) 21%, rgba(255,255,255,.2) 34%, transparent 35%, transparent),
radial-gradient(circle at 0% 50%, transparent 20%, rgba(255,255,255,.2) 21%, rgba(255,255,255,.2) 34%, transparent 35%, transparent) 0 -50px;
background-color: rgb(154, 160, 165);
background-size:75px 100px;" data-overlay="5">

        <%- body %>

    <script src="/js/vendors.min.js"></script>
    <script src="/dependencies/assets/icons/feather-icons/feather.min.js"></script>
    <script src="/js/pages/toastr.js"></script>
    <% if ( errors ) { %> 
    <script>
      $(function() {
        let testVar = "<%- errors %>";

        console.log(`test, ${locals}`);
      })
    </script>
    <% } %> 
</body>
</html>

```

You can see that I try to display the errors at the bottom of the view layout code in a script tag.

This is in the layout, but even if I do it in the view itself, it won't work, errors doesn't display any data, it doesn't even exist.