From 7355a42401ba7dfe3f931fab2885b105b3e43b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 15 Mar 2026 11:46:30 +0100 Subject: [PATCH 1/2] Add description and license MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index fe1e716..22b57f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,8 @@ name = "nomo" version = "0.1.0" edition = "2024" +description = "A templating library" +license = "EUPL-1.2" [[bench]] name = "parsing" From 5354d4ac7bf242360bdc80ad4d631e1930e9f91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 15 Mar 2026 12:07:40 +0100 Subject: [PATCH 2/2] Write some words into the README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- README.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa08854 --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# 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: + +```nomo +
+
    + {{ for notif in notifications }} +
  • {{= notif.text }}
  • + {{ end }} +
+
+``` + +It supports the following features: + +**If/Else Conditionals** + +```nomo +{{ if user.level > 3 }} + ... +{{ else if value == 1 }} + ... +{{ else }} + ... +{{ end }} +``` + +**For Loops** + +```nomo +{{ for user in users }} + {{= user.name }} +{{ end }} +``` + +**Whitespace Supression** + +```nomo +Hello +{{- if world == 2 -}} + Hi +{{- end }} +``` + +will print `Hello Hi`. + +**Function Calls** + +```nomo +{{= uppercase(user_name) }} +``` + +One can use function chaining for less nesting: + +```nomo +{{= 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. + +```nomo +{{= 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: + +```nomo +{{= 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.