Creating controllers and views
In MVC applications, the views display the data, which comes from the model layer to the user. However, the views do not interact directly with the model layer. Instead, they interact with the controller layer. The controller layer is responsible for handling user input and updating the model data, too. Every time a web request is made to the server, first, the controller is invoked, reading and/or modifying the model data. Then, this model data is passed to the view layer, which formats and displays the data to the user. Let’s see this in action in our app. Genie’s generator will create a controller for us:
julia> Genie.Generator.newcontroller("Todo")
The controller file is in the same location as our model, as indicated by the following output:
[ Info: New controller created at TodoMVC/app/resources/todos/TodosController.jl
Let’s add logic to display all the todos. We’ll start by adding a function...