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