Skip to content

leven-the-blog/tenjin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

tenjin

docs.rs crates.io

Buzzwords

  • dynamic
  • zero-allocation in render
  • logic-less
  • enables structural sharing

Template Syntax

{ if path.to.item } ... { end }
{ for item in path.to.items } ... { end }
{ include template_name }
{ path.to.item }

To escape { and }, use {{ and }}, respectively.

Macro Syntax

A macro can be used so that you can pass your own structs in as data to your templates.

context! {
    self: (TYPE PARAMETERS) TYPE {
        key1 => self.value,
        key2 => @iter self.iterable,
        key3 => @raw self.html,
        key4 => @{
            key5 => self.another_value,
            ...
        },
        ...
    }
}

You might also want to see the macros example. Note that these "contexts" are composable.

Truthiness

  1. All undefined values are falsey.
  2. Objects, maps and arrays are truthy.
  3. Booleans evaluate to their own value.
  4. Integers are truthy iff they are non-zero.
  5. Strings are truthy iff they are non-empty.
  6. Try to make truthiness as unsurprising as possible.

Contributing

Features will be added as they are needed. If you think something is missing, please open an issue!