[][src]Crate hatter

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

builtin

Hatter comes with a few built-in functions to help make your life easier, all defined in this module.

prelude

Args, Env, Result, and Value

value

Value is the dynamic type that represents an active Hatter object, including objects you define in your own code.

Structs

Args

The Args struct makes it easier to work with arguments when writing Hatter functions in Rust.

Env

Env is the top-level environment in which a Hatter template is evaluated and rendered.

Error

Usually source-related.

Interner

Interner creates and manages our string cache.

OMap

A HashMap for Hatter that preserves insertion order.

Symbol

A Symbol is an interned String, created and managed by Interner and stored in CACHE.

Tag

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.

Template

Compiled HTML template.

Token

A Token is an element of source code, a Syntax and its position.

Enums

ErrorKind

What kind of error?

Fn

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.

Jump

Error-ish that lets us abort what we're doing.

Stmt

Stmt is an AST node.

Syntax

The different types of syntax that our Lexer recognizes.

Value

Value is the dynamic type that represents an active Hatter object, including objects you define in your own code.

Traits

Object

If you want to expose your own structs to Hatter code, this is the trait for you.

SyntaxTrait

Helper method we add to char.

Functions

compile

Compile source code into a Vec of Stmt, aka the AST.

eval

Eval a list of Stmts and return the last's Value.

line_and_col

Calculate line # and col position for a position in a source file.

parse

Main method. Turn a slice of Token into a Vec of Stmt.

print_error

Pretty-print an error message, complete with colors and the line in question.

render

Render source to a String.

scan

Scans source code and produces a list of Tokens.

Type Definitions

Native

Hatter function defined in Rust.

Result

Alias for a generic Result type.

Scope

You know what it is.

Special

Hatter function defined in Rust whose arguments aren't evaluated, like a macro.