Suika Templates
Suika Templates is a simple template engine for the Suika web stack, enabling dynamic HTML generation.
Note: Suika is under active development and not intended for production use. The API is subject to change and may lack comprehensive testing and documentation.
Features
- Parse and render templates with context values.
- Support for template directives such as variables, conditionals, loops, extends, includes, and blocks.
- Load templates from files or directories.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Template Directives
The suika_templates library supports various directives within templates:
- Variables:
{{ variable_name }} - Conditionals:
{% if condition %} ... {% else %} ... {% endif %} - Loops:
{% for item in items %} ... {% endfor %} - Extends:
{% extend "base.html" %} - Includes:
{% include "header.html" %} - Blocks:
{% block content %} ... {% endblock %}
Usage
Here's an example of how to use suika_templates to parse and render a
template:
use ;
use HashMap;
Loading Templates from Directory
You can also load multiple templates from a directory:
use TemplateEngine;
use HashMap;