import type { TemplateStatement, ValueStatement } from './parser/statements.js'; import type { Helper } from './runner/helpers/type.js'; import type { LiteralValue } from './runner/index.js'; import type { BigodinOptions } from './runner/options.js'; /** * @param {object?} context Context to be used when evaluating the template. * @param {BigodinOptions?} options Options to be used. * @return {Promise} Promise that resolves to the rendered template. */ export type TemplateRunner = (context?: object, options?: BigodinOptions) => Promise; /** * Bigodin class, used if you need custom settings or helpers * not present in the default functions. */ declare class Bigodin { private readonly helpers; /** * Parses a template and returns an AST representing it. * This can be persisted as JSON for later usage. * * @param {string} template Bigodin template to be parsed * @return {TemplateStatement} AST representing input template */ parse: (template: string) => TemplateStatement; /** * Parses a bigodin expression into its AST representation. * This can be persisted as JSON for later usage. * * @param {string} expression Bigodin expression to be parsed * @return {ValueStatement} AST representing input expression */ parseExpression: (expression: string) => ValueStatement; /** * Runs an AST returned by the {@link Bigodin#parse} method. * * @param {TemplateStatement} ast AST returned by {@link Bigodin#parse}. * @param {object?} context Context to be used when evaluating the template. * @param {BigodinOptions?} options Options to be used. * @return {Promise} Promise that resolves to the rendered template. */ run: (ast: TemplateStatement, context?: object, options?: BigodinOptions) => Promise; /** * Runs an AST returned by the {@link Bigodin#parseExpression} method. * * @param {ValueStatement} statement AST returned by {@link Bigodin#parseExpression}. * @param {object?} context Context to be used when evaluating the expression. * @param {BigodinOptions?} options Options to be used. * @return {Promise} Promise that resolves to the rendered expression. */ runExpression: (statement: ValueStatement, context?: object, options?: BigodinOptions) => Promise; /** * Compiles a template and returns a function that, when called, executes it * * @param {string} template Bigodin template to be parsed * @return {TemplateRunner} Function that executes the template */ compile: (template: string) => TemplateRunner; /** * Compiles an expression and returns a function that, when called, executes it * * @param {string} expression Bigodin expression to be parsed * @return {TemplateRunner} Function that executes the template */ compileExpression: (expression: string) => ((context?: object, options?: BigodinOptions) => Promise); /** * Adds a helper to the Bigodin instance. * * @param {string} name Name of the helper when used in templates * @param {Function} helper Function to be executed when helper is called * @return {Bigodin} Returns the Bigodin instance for chaining */ addHelper: (name: string, helper: Helper) => this; } /** * Parses a template and returns an AST representing it. * This can be persisted as JSON for later usage. * * @param {string} template Bigodin template to be parsed * @return {TemplateStatement} AST representing input template */ export declare const parse: (template: string) => TemplateStatement, parseExpression: (expression: string) => ValueStatement; /** * Runs an AST returned by the {@link parse} method. * * @param {TemplateStatement} ast AST returned by {@link parse}. * @param {object?} context Context to be used when evaluating the template. * @param {BigodinOptions?} options Options to be used. * @return {Promise} Promise that resolves to the rendered template. */ export declare const run: (ast: TemplateStatement, context?: object, options?: BigodinOptions) => Promise, runExpression: (statement: ValueStatement, context?: object, options?: BigodinOptions) => Promise; /** * Compiles a template and returns a function that, when called, executes it * * @param {string} template Bigodin template to be parsed * @return {TemplateRunner} Function that executes the template */ export declare const compile: (template: string) => TemplateRunner, compileExpression: (expression: string) => ((context?: object, options?: BigodinOptions) => Promise); export type { TemplateStatement } from './parser/statements.js'; export type { BigodinOptions } from './runner/options.js'; export { Bigodin }; export default Bigodin;