Getting started
We'll create an example that is fully available and installable through the installation process. However, it's recommended that you begin without relying on existing examples, as this tutorial will guide you through building the example step by step.
Let us start with a minor example that we will improve upon throughout the guide.
Add Routes
Begin by updating the router file located at src/routes/app.js
as follows:
Visit your browser to see the results.
There's nothing wrong with managing code this way. However, as the app grows larger, this approach can become challenging, particularly when the router file starts to become lengthy. This is where template layout views and controllers come in handy. They improve the manageability and modularity of your app, making it easier to organize and maintain.
Creating Your Page
Let's begin by exploring Stratox's template system for creating dynamic layout and block components. Later on, we'll discuss controllers.
Proceed by creating a new template layout file named src/templates/views/Start.js
.
Modifying the Router Example
To create dynamic start and about pages, you only need to update the router file src/routes/app.js
as shown below:
First, add an import statement at the top of the router file to import the view:
Next, integrate the views into each router callable:
Note: You can reuse the same view multiple times within the same method, as explained in more detail in the views section.
Visit your browser to see the results.
Last updated