Variables will allow you to access data passed into the renderer from the controller.


To assign a variable we would create it in the controller when render() is called. For example, if we were to create a route that renders a view with name in the data like this.

Router.get('/', client => client.response.render('main.mix', {
  name: 'Billy'

We could then access that variable within the template.

Template assignment

The only way to assign a variable in a template is when using an each or for. Otherwise variables must be initiated within the controllers render() call.

Template access

To access a variable that has already been created within the template you would create double braces {{}} and prefix the variable with a $ within the braces. To utilizes the name variable it would look something like this.

    Hello {{$name}}