Skip to main content

Crate slumber_template

Crate slumber_template 

Source
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’s FromStr implementation to convert to T.

Structs§

Arguments
Arguments passed to a function call
FunctionCall
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.
RenderedChunks
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.
TemplateParseError
An error while parsing a template
WithValue
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 Error itself 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
RenderError
Any error that can occur during template rendering.
RenderedChunk
A piece of a rendered template string. A collection of chunks collectively constitutes a rendered string when displayed contiguously.
StreamSource
Metadata about the source of a Stream. This helps consumers present the stream to the user, e.g. in a template preview
TemplateChunk
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:
ValueError
An error that can occur while converting from Value to some other type. This is returned from TryFromValue.
ValueStream
A template output value that may be a concrete value or a stream

Traits§

Context
Context defines how template fields and functions are resolved. Both field resolution and function calls can be asynchronous.
FunctionOutput
Convert any value into Result<Value, RenderError>
TryFromValue
Convert Value to a type fallibly