Layout Inheritance
-
Rule: Templates SHOULD use layout inheritance with
{layout}for consistent page structure.
Example (Layout - @layout.latte):
<!DOCTYPE html>
<html>
<head>
<title>{block title}Default Title{/block}</title>
{block head}{/block}
</head>
<body>
<header>
{include 'partials/header.latte'}
</header>
<main>
{block content}{/block}
</main>
<footer>
{include 'partials/footer.latte'}
</footer>
{block scripts}{/block}
</body>
</html>
Example (Page template):
{layout '@layout.latte'}
{block title}Product Detail{/block}
{block content}
<h1>{$product->name}</h1>
<p>{$product->description}</p>
{/block}
Block Naming
-
Rule: Block names MUST be in camelCase.
Example:
{block content}{/block}
{block sidebarContent}{/block}
{block pageScripts}{/block}
Include and Import
-
Rule: Use
{include}for including template files and{import}for importing block definitions.
Example:
<!-- Include a partial -->
{include 'partials/product-card.latte', product => $item}
<!-- Import blocks from another file -->
{import 'blocks/forms.latte'}
Summary:
- Use
{layout}for layout inheritance. - Block names MUST be in camelCase.
- Use
{include}for partials and{import}for block definitions.