How views work
Learn how to use views to create custom layouts for your data apps.
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 called views/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
.
index.html
and the name of the route is determined by the directory or folder where it is placed.If you have a file named 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 the views
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
.
Next steps
Now that you know how to use views, you can start creating views for your data apps. To learn more about how to use layouts to display your data, check out the Layout docs.