Template
Builds HTTP response text from template literals.
Template interpolations can be plain values, optional values, effects, or streams. The resulting effect or stream keeps the errors and service requirements from any effectful interpolations, which lets response helpers assemble dynamic text without losing type information.
Constructors
Signature
declare function make<A extends readonly Array<Interpolated>>(strings: TemplateStringsArray, ...args: A): Effect<string, Error<A[number]>, Context<A[number]>>Creates a stream of strings from a template literal.
Details
Static text is emitted with interpolated values. Effect interpolations are evaluated as stream chunks, and stream interpolations are flattened into the output.
Signature
declare function stream<A extends readonly Array<InterpolatedWithStream>>(strings: TemplateStringsArray, ...args: A): Stream<string, Error<A[number]>, Context<A[number]>>Models
Interpolated type
Value accepted by the string template constructor.
Details
Interpolations can be primitive values, optional primitive values, or effects that produce primitive values.
Signature
type Interpolated = Primitive | Option.Option<Primitive> | Effect.Effect<Primitive, any, any>;InterpolatedWithStream type
Value accepted by the streaming template constructor.
Details
In addition to normal interpolations, stream interpolations can emit primitive values over time.
Signature
type InterpolatedWithStream = Interpolated | Stream.Stream<Primitive, any, any>;Primitive template interpolation value.
Details
Arrays are rendered by converting each element to a string and concatenating the results.
Signature
type Primitive = PrimitiveValue | ReadonlyArray<PrimitiveValue>;PrimitiveValue type
Primitive value that can be interpolated into an HTTP template.
Signature
type PrimitiveValue = string | number | bigint | boolean | null | undefined;Other
Interpolated
Namespace containing type-level helpers for template interpolations.
Creates an effectful string from a template literal.
Details
Primitive and
Optioninterpolations are rendered immediately. Effect interpolations are evaluated and rendered before the final string is produced.