Expand description
Generate strings (and bytes) from user-written templates with dynamic data. This engine is focused on rendering templates, and is generally agnostic of its usage in the rest of the app. As such, there is no logic in here relating to HTTP or other Slumber concepts.
Macros§
- impl_
try_ from_ value_ str - Implement TryFromValue for the given type by converting the Value to a
String, then using
T’sFromStrimplementation to convert toT.
Structs§
- Arguments
- Arguments passed to a function call
- Function
Call - Function call in a template expression:
f(true, 0, kwarg0="hello") - Identifier
- An identifier that can be used in a template key. A valid identifier is
any non-empty string that contains only alphanumeric characters,
-, or_. The first character must be a letter or underscore. Hyphens and numbers are not allowed first to avoid ambiguity with number literals. - Rendered
Chunks - Outcome of rendering the individual chunks of a template. This is an intermediate output type that can be resolved into a variety of final output types.
- Template
- A parsed template, which can contain raw and/or templated content. The string is parsed during creation to identify template keys, hence the immutability.
- Template
Parse Error - An error while parsing a template
- With
Value - An error with a value attached. Use this for errors that originated from a
particular value, so that the offending value can be included in the error
message. This does not implement
Erroritself as it’s just meant as a container to pass an error+value together. It should be unpacked into another error variant to provide better context to the user.
Enums§
- Expected
- When a value of a particular type is expected but something else is given
- Expression
- A dynamic segment of a template that will be computed at render time. Expressions are derived from the template context and may include external data such as loading a file.
- Literal
- Literal primitive value
- Render
Error - Any error that can occur during template rendering.
- Rendered
Chunk - A piece of a rendered template string. A collection of chunks collectively constitutes a rendered string when displayed contiguously.
- Stream
Source - Metadata about the source of a Stream. This helps consumers present the stream to the user, e.g. in a template preview
- Template
Chunk - A parsed piece of a template. After parsing, each chunk is either raw text or a parsed key, ready to be rendered.
- Value
- A runtime template value. This very similar to a JSON value, except:
- Value
Error - An error that can occur while converting from Value to some other type. This is returned from TryFromValue.
- Value
Stream - A template output value that may be a concrete value or a stream
Traits§
- Context
Contextdefines how template fields and functions are resolved. Both field resolution and function calls can be asynchronous.- Function
Output - Convert any value into
Result<Value, RenderError> - TryFrom
Value - Convert Value to a type fallibly