Macro ssg::macro_render_layout
source · macro_rules! macro_render_layout { ($layout:expr, $template_path:expr, $context:expr) => { ... }; }
Expand description
macro_render_layout Macro
This macro selects and renders a specified layout with a given context.
-
$layout: The desired layout name (e.g., “contact”, “index”, “page”). If a template file corresponding to$layout.htmlexists in the template directory, it will be used. Otherwise, the macro falls back to predefined mappings. -
$template_path: The path to the directory containing the template files. -
$context: The context to be rendered into the template.
Behaviour:
- If a file named
$layout.htmlexists in$template_path, it will be used as the template. - If no such file exists, the macro checks for predefined layout names:
- “contact” maps to “contact.html”
- “index” maps to “index.html”
- “page” maps to “page.html”
- If
$layoutis unrecognized and doesn’t correspond to a file in the template directory, the macro defaults to using “index.html”.
Returns:
The macro returns a rendered string using the selected template and provided context.