No description
Find a file
Marcel Müller a590839b21 Add parsing of dot operator
Signed-off-by: Marcel Müller <neikos@neikos.email>
2026-03-15 13:39:08 +01:00
benches Rename ast to parser 2026-03-15 11:33:40 +01:00
fuzz Rename emit to compiler 2026-03-15 11:45:32 +01:00
src Add parsing of dot operator 2026-03-15 13:39:08 +01:00
tests Add conditional value emitting 2026-03-15 12:46:00 +01:00
.envrc Initial Version 2024-11-21 16:06:21 +01:00
.gitignore Add simple bench 2026-03-08 16:12:56 +01:00
Cargo.lock Use macro per-test-file 2026-03-12 18:15:20 +01:00
Cargo.toml Add description and license 2026-03-15 11:46:30 +01:00
flake.lock Add parsing for conditionals (cont.) 2026-03-08 15:06:29 +01:00
flake.nix Add fuzzing 2026-03-09 15:20:02 +01:00
README.md Write some words into the README 2026-03-15 12:07:40 +01:00
rust-toolchain.toml Add parsing for conditionals (cont.) 2026-03-08 15:06:29 +01:00
rustfmt.toml Initial Version 2024-11-21 16:06:21 +01:00

Nomo, a simple templating library

Nomo is pure Rust templating library meant to be unopinionated in which target language it is embedded.

Here is an example nomo HTML snippet:

<div id="notifications">
    <ul>
        {{ for notif in notifications }}
            <li class="notification-{{= notif.level }}">{{= notif.text }}</li>
        {{ end }}
    </ul>
</div>

It supports the following features:

If/Else Conditionals

{{ if user.level > 3 }}
    ...
{{ else if value == 1 }}
    ...
{{ else }}
    ...
{{ end }}

For Loops

{{ for user in users }}
  {{= user.name }}
{{ end }}

Whitespace Supression

Hello
{{- if world == 2 -}}
 Hi
{{- end }}

will print Hello Hi.

Function Calls

{{= uppercase(user_name) }}

One can use function chaining for less nesting:

{{= user_name | uppercase }}

The | operator has the lowest precedence of the operators. Functions can still be given arguments. It is always the last argument that is 'applied' by the operator.

{{= username? | or_default("Unknown") }}

Undefined Chaining

Per default, trying to access a value that is not defined will cause an error.

This can be changed with the ? operator. This can be applied at any level:

{{= user?.profile.description? }}

This will give an error if user.profile is not defined. If either user or description is missing, it simply does not render anything (akin to an empty string). However if there is an user, it must have a profile value.