TemplateFormatter overview
This module implements a CVTemplateFormatter, i.e. an object that is capable of converting a a record of values to a string according to the CVTemplate that was used to construct it. If you don’t want to build a CVTemplate beforehand, you can also construct a CVTemplateFormatter directly from CVTemplatePart’s
Table of contents
Constructors
{ fromTemplate }
Constructor of a CVTemplateFormatter from a CVTemplate
Signature
export declare const { fromTemplate }: any
{ fromTemplateParts }
Constructor of a CVTemplateFormatter directly from CVTemplateParts
Signature
export declare const { fromTemplateParts }: any
Getters
format
Returns the format property of self.
Signature
export declare const format: <PlaceholderTypes extends MTypes.Object>(
self: Type<PlaceholderTypes>
) => Type<PlaceholderTypes>["format"]
formatOrThrow
Returns the formatOrThrow property of self.
Signature
export declare const formatOrThrow: <PlaceholderTypes extends MTypes.Object>(
self: Type<PlaceholderTypes>
) => Type<PlaceholderTypes>["formatOrThrow"]
Models
Type (class)
Type that represents a CVTemplateFormatter
Signature
export declare class Type<PlaceholderTypes> {
private constructor({ description, format, formatOrThrow }: MTypes.Data<Type<PlaceholderTypes>>)
}
make (static method)
Class constructor
Signature
private static make({
syntheticDescription,
placeholderDescription,
templateParts,
}: {
readonly syntheticDescription: string;
readonly placeholderDescription: string;
readonly templateParts: CVTemplateParts.Type;
}): Type<any>
fromTemplate (static method)
Constructor of a CVTemplateFormatter from a CVTemplate
Signature
static fromTemplate<PlaceholderTypes extends MTypes.Object>(
this: void,
template: CVTemplate.Type<PlaceholderTypes>,
): Type<PlaceholderTypes>
fromTemplateParts (static method)
Constructor of a CVTemplateFormatter directly from CVTemplateParts
Signature
static fromTemplateParts<const PS extends CVTemplateParts.Type>(
this: void,
...templateParts: PS
): Type<CVTemplateParts.ToPlaceHolderTypes<PS>>
[MData.idSymbol] (method)
Returns the id of this
Signature
[MData.idSymbol](): string | (() => string)
description (property)
Description of this CVTemplateFormatter
Signature
readonly description: string
format (property)
Function that tries to format a record according to the template passed to build this formatter
Signature
readonly format: MTypes.OneArgFunction<PlaceholderTypes, Result.Result<string, MInputError.Type>>
formatOrThrow (property)
Same as format but throws in case of failure
Signature
readonly formatOrThrow: MTypes.OneArgFunction<PlaceholderTypes, string>
Module markers
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/conversions/formatting/template/TemplateFormatter/"