-
Book Overview & Buying
-
Table Of Contents
Web Development with Julia and Genie
By :
Let’s add a route to our app. Edit the routes.jl file inside the TodoMVC folder and change it to look like this:
using Genie
using TodoMVC.TodosController
route("/", TodosController.index)
The route(…) line tells us that when the root folder of the app is requested, the index function in TodosController.jl must be called. From the previous section, we already know what will then be displayed. We can access our todos at http://localhost:8000/, and we can now see the one to-do item we previously created:
Figure 4.5 – The index page
When rendering a view file, by default, it is automatically wrapped by a layout file. The role of the layout is to render generic UI elements that are present on multiple pages, such as the main navigation or the footer. The default layout file is located in the app/layouts folder and is called app.jl.html. Let’s use it to...