UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

38 lines (37 loc) 1.41 kB
type EvaluateTemplateOptions = { /** If true, the template is always treated as a template even if it isn't wraped in {{}} */ forceEvaluate?: boolean; }; /** * Hook that evaluates a template with the given args. * * Returns the result and error of the evaluation. * * Also returns an initial loading flag that is true until the first result is returned * and a loading flag that is true while any evaluation is in progress. */ export declare const useEvaluateTemplate: (template?: Template | string, args?: Record<string, unknown>, opts?: EvaluateTemplateOptions) => { result: unknown; error: string; loading: boolean; initialLoading: boolean | 0 | undefined; }; /** * Hook that evaluates multiple templates with the given args. * * Returns the results and errors of the evaluation as an array that corresponds to the input templates. * * Also returns an initial loading flag that is true until all templates have been evaluated once * and a loading flag that is true while any evaluation is in progress. */ export declare const useEvaluateTemplates: (templates?: Array<string | Template | undefined>, args?: Record<string, unknown>, opts?: EvaluateTemplateOptions) => { results: unknown[]; errors: string[]; initialLoading: boolean | 0 | undefined; loading: boolean; }; type Template = { __airplaneType: "template"; raw: string; }; export {};