Base Template
The Base Templates are normal components you just wrap your page code in this Base Component.
The Base Template/Component is same as normal component importing and usage is also same but the idea is to not write basic html boilerplate code like doctype and meta tags multiple times for the same project.
The only thing that changes in the Boilerplate code of HTML is Title content of your page or maybe the meta tags description to make it dynamic you can use Component Parameters.
Here is a complete example code of a Base Template that have a dynamic title for each page.
serve (
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>@(title)</title>
</head>
<body>
@(slot)
</body>
</html>
)@(slot) parameter is necessary without it your code will not shown.
Now the Page code that will use the above template.
as Base import "../base"
serve (
<Base title="Landing Page">
<!-- Your Whole Page content will goes here -->
</Base>
)Note
-
The
@(title)in/views/base.zarewill be replaces withLanding Page. -
The
@(slot)in/views/pages/index.zarewill be replaces with your page content.
Imagine
You can easily imagine the structure of how your code will be look like after using Base templates and Components in your main page file.
