import { Node, Root } from "./ast"; import { RenderContext } from "./context"; import { Environment, EnvironmentOptions, TemplateContext } from "./environment"; import { RenderStream } from "./io/output_stream"; import { TemplateAnalysis, TemplateAnalysisOptions } from "./static_analysis"; import { ContextScope } from "./types"; export type { TemplateAnalysis, TemplateAnalysisOptions, VariableRefs, VariableLocation, VariableLocations, } from "./static_analysis"; /** * A Liquid template that has been parsed and is bound to an environment, * ready to be rendered. Rather than constructing a template directly, you * should use `Template.fromString()`, `Environment.fromString()` or * `Environment.getTemplate()`. */ export declare class Template { readonly environment: Environment; readonly tree: Root; readonly name: string; readonly globals: ContextScope; readonly matter: ContextScope; readonly loaderContext: ContextScope; readonly isUpToDate: () => Promise; readonly isUpToDateSync: () => boolean; protected renderContextClass: typeof RenderContext; /** * Parse a Liquid template, automatically creating an environment to * bind it to. * * @param source - The Liquid template source code. * @param templateGlobals - Global render context variables that will * included every time this template is rendered. * @param options - Options to set on the implicit environment. `globals` * and `loader` will be ignored when creating an implicit environment. * @returns A new template, bound to an implicit environment. */ static fromString(source: string, templateGlobals?: ContextScope, options?: EnvironmentOptions): Template; /** * Parse a Liquid template, automatically creating an environment to * bind it to. * * Alias of {@link fromString} * * @param source - The Liquid template source code. * @param templateGlobals - Global render context variables that will * included every time this template is rendered. * @param options - Options to set on the implicit environment. * @returns A new template, bound to an implicit environment. */ static from(source: string, templateGlobals?: ContextScope, options?: EnvironmentOptions): Template; /** * Template constructor. Rather than constructing a template directly, you * should use `Template.fromString()`, `Environment.fromString()` or * `Environment.getTemplate()`. * * @param environment - The environment this template is bound to. * @param tree - The root of the abstract syntax tree representing this * template. * @param globals - An optional object who's properties will be added * to the render context every time the resulting template is rendered. * @param templateContext - Optional meta data. Mostly for managing loading * and reloading of templates. */ constructor(environment: Environment, tree: Root, globals?: ContextScope, templateContext?: TemplateContext); /** * Render the template. * @param globals - An optional object who's properties will be added * to the render context, * @returns The rendered template. */ render(globals?: ContextScope): Promise; /** * A synchronous version of `render`. * @see {@link render} */ renderSync(globals?: ContextScope): string; protected handleError(error: unknown, node: Node, blockScope: boolean, partial: boolean): void; /** * Render a template given an existing render context and output stream. * This is used by the built-in `include` and `render` tags. */ renderWithContext(context: RenderContext, outputStream: RenderStream, blockScope?: boolean, partial?: boolean): Promise; /** * A synchronous version of `renderWithContext`. * @see {@link renderWithContext} */ renderWithContextSync(context: RenderContext, outputStream: RenderStream, blockScope?: boolean, partial?: boolean): void; /** * Copy this template with new render context globals. * * @param globals - An object who's properties will be added * to the render context every time this template is rendered. * @returns A copy of this template with new render context globals. */ withGlobals(globals?: ContextScope): Template; /** * Combine render context global variables from the bound environment, * the "matter" object originating from a template loader (if any) and * those passed to `render()`. * * Override this to change global template scope priorities. */ protected makeGlobals(templateGlobals: ContextScope): ContextScope; /** * Statically analyze this template and any included/rendered templates. * Currently we only analyze references to template variables. * * @param options - Template analysis options. */ analyze({ followPartials, raiseForFailures, }?: TemplateAnalysisOptions): Promise; /** * A synchronous version of `analyze` * @see {@link analyze} * @param options - Template analysis options. */ analyzeSync({ followPartials, raiseForFailures, }?: TemplateAnalysisOptions): TemplateAnalysis; }