Expand description
Hatter is a small, whitespace sensitive templating language with HTML support built right in. Its HTML features and syntax are a cheap knock off of Imba, except Hatter produces raw, static HTML - no JavaScript in sight. Hatter can be used to generate static web sites or to render server side content in a good ol’ fashioned web application - either with Vial or your Rust web framework of choice. If you’re feeling adventerous, or mad as a hatter, you can use the standalone binary to turn templates into HTML files or include the zero-dependency Rust library in your (web/cli/?) application.
Modules§
- Hatter comes with a few built-in functions to help make your life easier, all defined in this module.
- Args, Env, Result, and Value
- Value is the dynamic type that represents an active Hatter object, including objects you define in your own code.
Structs§
- The
Args
struct makes it easier to work with arguments when writing Hatter functions in Rust. - Env is the top-level environment in which a Hatter template is evaluated and rendered.
- Usually source-related.
- Interner creates and manages our string cache.
- A HashMap for Hatter that preserves insertion order.
- A Symbol is an interned String, created and managed by
Interner
and stored in CACHE. - Since HTML tags are a bit more involved than IF statements or variable assignment, they have their own data structure. This is still basically just a Stmt, though.
- Compiled HTML template.
- A Token is an element of source code, a
Syntax
and its position.
Enums§
- What kind of error?
- Three types of functions in Hatter: Fn: Function defined in Hatter. Native: Function defined in Rust. Special: Function defined in Rust whose arguments aren’t evaluated, like a macro.
- Error-ish that lets us abort what we’re doing.
- Stmt is an AST node.
- The different types of syntax that our
Lexer
recognizes. - Value is the dynamic type that represents an active Hatter object, including objects you define in your own code.
Traits§
- If you want to expose your own structs to Hatter code, this is the trait for you.
- Helper method we add to
char
.
Functions§
- Compile source code into a Vec of Stmt, aka the AST.
- Eval a list of Stmts and return the last’s Value.
- Calculate line # and col position for a position in a source file.
- Main method. Turn a slice of
Token
into a Vec ofStmt
. - Pretty-print an error message, complete with colors and the line in question.
- Render source to a String.
- Scans source code and produces a list of
Token
s.
Type Aliases§
- Hatter function defined in Rust.
- Alias for a generic Result type.
- You know what it is.
- Hatter function defined in Rust whose arguments aren’t evaluated, like a macro.