Introduction
Views are a powerful way to create custom layouts for your data apps. They allow you to create reusable components that can be used to display your data in a variety of ways. In this guide, we’ll take a look at how to use views.Routing
In a Latitude data app, routes are inferred from the file structure of your app. For example, if you have a file calledviews/index.html
, it will be accessible at the root of your app.
To create more pages you need nested routes. You can do this by creating a directory with the same name as the route or page you want to create. For example, if you have a file called views/charts/index.html
, it will be accessible at /charts
. Consequently, if you have a file called views/charts/bar/index.html
, it will be accessible at /charts/bar
.
So view files must be named as
index.html
and the name of the route is determined by the directory or folder where it is placed.views/about.html
, it won’t be accessible because we only allow one file at root level and only files named index
.
If you have both a file and a directory with the same name, the framework will throw an error.
Static files and assets
Every file in theviews
directory is publicly accessible. This means that you can use them to serve static files and assets like images, CSS, and JavaScript files. For example, if you have an image called logo.png
in the views
directory, you can access it at /logo.png
.