UNPKG

@mdfriday/foundry

Version:

The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.

161 lines 5.26 kB
/** * Template functions registry * Centralized management of template functions following DDD principles * TypeScript equivalent of Go's valueobject/nsreg.go */ import { CustomizedFunctions, TemplateFuncMap } from '../type'; import { TemplateEngine } from '../entity/template'; /** * Template functions registry interface * Domain service for managing template function registration */ export interface TemplateRegistry { registerCoreFunctions(funcMap: TemplateFuncMap): void; registerExtendedFunctions(funcMap: TemplateFuncMap, services: CustomizedFunctions): void; registerAllFunctions(funcMap: TemplateFuncMap, services?: CustomizedFunctions): void; } /** * Template functions registry implementation * Following DDD principles - encapsulates template function management logic */ export declare class DefaultTemplateRegistry implements TemplateRegistry { /** * Register core template functions that don't require external services * Equivalent to Go's RegisterNamespaces() */ registerCoreFunctions(funcMap: TemplateFuncMap): void; /** * Register cryptographic hash functions * Equivalent to Go's crypto packages */ private registerCryptoFunctions; /** * Register extended template functions that require external services * Equivalent to Go's RegisterExtendedNamespaces() */ registerExtendedFunctions(funcMap: TemplateFuncMap, services: CustomizedFunctions): void; /** * Register all available functions with services * This is the main entry point for function registration */ registerAllFunctions(funcMap: TemplateFuncMap, services?: CustomizedFunctions): void; /** * Register functions that depend on TemplateEngine * These functions are registered with placeholder implementations initially */ private registerEngineDependentFunctions; /** * Register URL template functions using URLService * Equivalent to Go's registerUrls() */ private registerURLFunctions; /** * Register site template functions using SiteService * Equivalent to Go's registerSite() */ private registerSiteFunctions; private registerResourcesFunctions; /** * Register Hugo template functions using HugoInfoService * Equivalent to Go's registerHugo() */ private registerHugoFunctions; /** * Register language template functions using LanguageService * Equivalent to Go's registerLang() */ private registerLanguageFunctions; /** * Register string manipulation functions * Equivalent to Go's registerStrings() */ private registerStringFunctions; /** * Register math functions * Equivalent to Go's registerMath() */ private registerMathFunctions; /** * Register time/date functions * Equivalent to Go's registerTime() */ private registerTimeFunctions; /** * Register collection functions * Equivalent to Go's registerCollections() */ private registerCollectionFunctions; /** * Core indexing implementation following Go's doIndex logic * Supports nested indexing of arrays, objects, and maps */ private doIndex; /** * Index into an array or slice */ private indexArray; /** * Index into a string (treating it like a character array) */ private indexString; /** * Index into an object/map (including TaxonomyList) */ private indexObject; /** * Convert value to integer, similar to Go's index conversion */ private toInteger; /** * Check condition between two values using the specified operator * Following golang's checkCondition logic */ private checkCondition; /** * Normalize values for comparison */ private normalizeForComparison; /** * Register safe functions * Equivalent to Go's registerSafe() */ private registerSafeFunctions; /** * Register format functions (fmt namespace) * Equivalent to Go's registerFmt() */ private registerFmtFunctions; /** * Register reflect functions * Equivalent to Go's registerReflect() */ private registerReflectFunctions; /** * Register path manipulation functions * Equivalent to Go's path package functions */ private registerPathFunctions; /** * Get nested value from object using dot notation path * Following golang's path resolution logic */ private getNestedValue; } /** * Create default template registry */ export declare function newTemplateRegistry(): TemplateRegistry; /** * Convenience function to create and register core functions only */ export declare function createCoreFuncMap(): TemplateFuncMap; /** * Convenience function to create and register all functions with services */ export declare function createStandardFuncMap(services: CustomizedFunctions): TemplateFuncMap; /** * Update all engine-dependent functions with the template engine instance * This should be called after the template engine is created */ export declare function updateEngineDependentFunctions(engine: TemplateEngine): void; //# sourceMappingURL=registry.d.ts.map