ecto 4.8.2 → 4.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -64
- package/dist/ecto.d.mts +403 -0
- package/dist/ecto.mjs +863 -0
- package/package.json +27 -25
- package/dist/ecto.d.ts +0 -400
- package/dist/ecto.js +0 -1042
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecto",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
4
4
|
"description": "Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, Liquid, and Handlebars",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/ecto.
|
|
7
|
-
"module": "./dist/ecto.
|
|
8
|
-
"types": "./dist/ecto.d.
|
|
6
|
+
"main": "./dist/ecto.mjs",
|
|
7
|
+
"module": "./dist/ecto.mjs",
|
|
8
|
+
"types": "./dist/ecto.d.mts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
11
|
+
"types": "./dist/ecto.d.mts",
|
|
12
|
+
"import": "./dist/ecto.mjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"repository": {
|
|
@@ -38,30 +39,31 @@
|
|
|
38
39
|
"liquidjs"
|
|
39
40
|
],
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@jaredwray/fumanchu": "^4.
|
|
42
|
-
"cacheable": "^2.3.
|
|
43
|
-
"ejs": "^
|
|
42
|
+
"@jaredwray/fumanchu": "^4.6.1",
|
|
43
|
+
"cacheable": "^2.3.4",
|
|
44
|
+
"ejs": "^5.0.1",
|
|
44
45
|
"ent": "^2.2.2",
|
|
45
|
-
"hookified": "^1.
|
|
46
|
-
"liquidjs": "^10.
|
|
46
|
+
"hookified": "^2.1.1",
|
|
47
|
+
"liquidjs": "^10.25.5",
|
|
47
48
|
"nunjucks": "^3.2.4",
|
|
48
|
-
"pug": "^3.0.
|
|
49
|
-
"writr": "^
|
|
49
|
+
"pug": "^3.0.4",
|
|
50
|
+
"writr": "^6.1.1"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@biomejs/biome": "^2.
|
|
53
|
-
"@faker-js/faker": "^10.
|
|
53
|
+
"@biomejs/biome": "^2.4.10",
|
|
54
|
+
"@faker-js/faker": "^10.4.0",
|
|
54
55
|
"@types/ejs": "^3.1.5",
|
|
55
56
|
"@types/ent": "^2.2.8",
|
|
56
|
-
"@types/node": "^25.
|
|
57
|
+
"@types/node": "^25.5.2",
|
|
57
58
|
"@types/nunjucks": "^3.2.6",
|
|
58
59
|
"@types/pug": "^2.0.10",
|
|
59
|
-
"@vitest/coverage-v8": "^4.
|
|
60
|
-
"docula": "^
|
|
61
|
-
"rimraf": "^6.1.
|
|
62
|
-
"
|
|
63
|
-
"typescript": "^
|
|
64
|
-
"
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.3",
|
|
61
|
+
"docula": "^1.12.0",
|
|
62
|
+
"rimraf": "^6.1.3",
|
|
63
|
+
"tsdown": "^0.21.7",
|
|
64
|
+
"typescript": "^6.0.2",
|
|
65
|
+
"vite": "^8.0.5",
|
|
66
|
+
"vitest": "^4.1.3"
|
|
65
67
|
},
|
|
66
68
|
"files": [
|
|
67
69
|
"dist",
|
|
@@ -71,11 +73,11 @@
|
|
|
71
73
|
"scripts": {
|
|
72
74
|
"lint": "biome check --write --error-on-warnings",
|
|
73
75
|
"lint:ci": "biome check --error-on-warnings",
|
|
74
|
-
"clean": "rimraf ./dist yarn.lock package-lock.json pnpm-lock.yaml ./coverage ./node_modules ./site/
|
|
76
|
+
"clean": "rimraf ./dist yarn.lock package-lock.json pnpm-lock.yaml ./coverage ./node_modules ./site/README.md ./site/dist",
|
|
75
77
|
"test": "pnpm lint && vitest run --coverage",
|
|
76
78
|
"test:ci": "pnpm lint:ci && vitest run --coverage",
|
|
77
|
-
"build": "
|
|
78
|
-
"website:build": "rimraf ./site/
|
|
79
|
-
"website:
|
|
79
|
+
"build": "tsdown",
|
|
80
|
+
"website:build": "rimraf ./site/README.md && pnpm docula build",
|
|
81
|
+
"website:dev": "rimraf ./site/README.md && pnpm docula dev"
|
|
80
82
|
}
|
|
81
83
|
}
|
package/dist/ecto.d.ts
DELETED
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import { Cacheable, CacheableMemory } from 'cacheable';
|
|
2
|
-
import { HookifiedOptions, Hookified } from 'hookified';
|
|
3
|
-
|
|
4
|
-
type EngineInterface = {
|
|
5
|
-
names: string[];
|
|
6
|
-
engine: any;
|
|
7
|
-
opts?: Record<string, unknown>;
|
|
8
|
-
rootTemplatePath?: string;
|
|
9
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
10
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
declare class EngineMap {
|
|
14
|
-
private readonly _mappings;
|
|
15
|
-
set(name: string, extensions: string[]): void;
|
|
16
|
-
delete(name: string): void;
|
|
17
|
-
deleteExtension(name: string, extension: string): void;
|
|
18
|
-
get(name: string): string[] | undefined;
|
|
19
|
-
getName(extension: string): string | undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare class BaseEngine {
|
|
23
|
-
names: string[];
|
|
24
|
-
opts?: Record<string, unknown>;
|
|
25
|
-
engine: any;
|
|
26
|
-
rootTemplatePath?: string;
|
|
27
|
-
private _extensions;
|
|
28
|
-
getExtensions(): string[];
|
|
29
|
-
setExtensions(extensions: string[]): void;
|
|
30
|
-
deleteExtension(name: string): void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare class EJS extends BaseEngine implements EngineInterface {
|
|
34
|
-
constructor(options?: Record<string, unknown>);
|
|
35
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
36
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare class Handlebars extends BaseEngine implements EngineInterface {
|
|
40
|
-
partialsPath: string[];
|
|
41
|
-
constructor(options?: Record<string, unknown>);
|
|
42
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
43
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
44
|
-
initPartials(): void;
|
|
45
|
-
registerPartials(partialsPath: string): boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
declare class Liquid extends BaseEngine implements EngineInterface {
|
|
49
|
-
constructor(options?: Record<string, unknown>);
|
|
50
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
51
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare class Markdown extends BaseEngine implements EngineInterface {
|
|
55
|
-
constructor(options?: Record<string, unknown>);
|
|
56
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
57
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
declare class Nunjucks extends BaseEngine implements EngineInterface {
|
|
61
|
-
constructor(options?: Record<string, unknown>);
|
|
62
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
63
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
declare class Pug extends BaseEngine implements EngineInterface {
|
|
67
|
-
constructor(options?: Record<string, unknown>);
|
|
68
|
-
render(source: string, data?: Record<string, unknown>): Promise<string>;
|
|
69
|
-
renderSync(source: string, data?: Record<string, unknown>): string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type EctoOptions = {
|
|
73
|
-
/**
|
|
74
|
-
* The default engine to use. This can be 'ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid'
|
|
75
|
-
* @default 'ejs'
|
|
76
|
-
* @type {string}
|
|
77
|
-
*/
|
|
78
|
-
defaultEngine?: string;
|
|
79
|
-
/**
|
|
80
|
-
* The engine options to pass to each engine
|
|
81
|
-
* @type {Record<string, Record<string, unknown>>}
|
|
82
|
-
* @default {}
|
|
83
|
-
* @example
|
|
84
|
-
* {
|
|
85
|
-
* nunjucks: {
|
|
86
|
-
* autoescape: true
|
|
87
|
-
* },
|
|
88
|
-
* markdown: {
|
|
89
|
-
* html: true
|
|
90
|
-
* }
|
|
91
|
-
* }
|
|
92
|
-
*/
|
|
93
|
-
engineOptions?: Record<string, Record<string, unknown>>;
|
|
94
|
-
/**
|
|
95
|
-
* Caching for async rendered templates. If set to true, it will use the default cacheable options.
|
|
96
|
-
* If set to Cacheable instantce, it will use the provided cacheable instance.
|
|
97
|
-
* @type {boolean | Cacheable}
|
|
98
|
-
* @default false
|
|
99
|
-
*/
|
|
100
|
-
cache?: boolean | Cacheable;
|
|
101
|
-
/**
|
|
102
|
-
* If set to true, it will cache the rendered templates synchronously when running renderSync.
|
|
103
|
-
* If set to CacheableMemory instance, it will use the provided cacheable memory instance.
|
|
104
|
-
* @type {boolean | CacheableMemory}
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
107
|
-
cacheSync?: boolean | CacheableMemory;
|
|
108
|
-
} & HookifiedOptions;
|
|
109
|
-
/**
|
|
110
|
-
* Context passed to beforeRender and beforeRenderSync hooks
|
|
111
|
-
*/
|
|
112
|
-
type RenderContext = {
|
|
113
|
-
source: string;
|
|
114
|
-
data?: Record<string, unknown>;
|
|
115
|
-
engineName: string;
|
|
116
|
-
rootTemplatePath?: string;
|
|
117
|
-
filePathOutput?: string;
|
|
118
|
-
cached: boolean;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Result passed to afterRender and afterRenderSync hooks
|
|
122
|
-
*/
|
|
123
|
-
type RenderResult = {
|
|
124
|
-
result: string;
|
|
125
|
-
context: RenderContext;
|
|
126
|
-
};
|
|
127
|
-
declare enum EctoEvents {
|
|
128
|
-
cacheHit = "cacheHit",
|
|
129
|
-
cacheMiss = "cacheMiss",
|
|
130
|
-
warn = "warn",
|
|
131
|
-
error = "error",
|
|
132
|
-
beforeRender = "beforeRender",
|
|
133
|
-
afterRender = "afterRender",
|
|
134
|
-
beforeRenderSync = "beforeRenderSync",
|
|
135
|
-
afterRenderSync = "afterRenderSync"
|
|
136
|
-
}
|
|
137
|
-
declare class Ecto extends Hookified {
|
|
138
|
-
private readonly _mapping;
|
|
139
|
-
private readonly _engines;
|
|
140
|
-
private _cache;
|
|
141
|
-
private _cacheSync;
|
|
142
|
-
private _defaultEngine;
|
|
143
|
-
private readonly _ejs;
|
|
144
|
-
private readonly _markdown;
|
|
145
|
-
private readonly _pug;
|
|
146
|
-
private readonly _nunjucks;
|
|
147
|
-
private readonly _handlebars;
|
|
148
|
-
private readonly _liquid;
|
|
149
|
-
/**
|
|
150
|
-
* Ecto constructor
|
|
151
|
-
* @param {EctoOptions} [options] - The options for the ecto engine
|
|
152
|
-
*/
|
|
153
|
-
constructor(options?: EctoOptions);
|
|
154
|
-
/**
|
|
155
|
-
* Get the default engine
|
|
156
|
-
* @returns {string} - the engine name such as 'ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid'
|
|
157
|
-
*/
|
|
158
|
-
get defaultEngine(): string;
|
|
159
|
-
/**
|
|
160
|
-
* Set the default engine
|
|
161
|
-
* @param {string} value the engine name such as 'ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid'
|
|
162
|
-
*/
|
|
163
|
-
set defaultEngine(value: string);
|
|
164
|
-
/**
|
|
165
|
-
* Get the cacheable instance
|
|
166
|
-
* @returns {Cacheable | undefined} - The cacheable instance or undefined if caching is disabled
|
|
167
|
-
*/
|
|
168
|
-
get cache(): Cacheable | undefined;
|
|
169
|
-
/**
|
|
170
|
-
* Set the cacheable instance
|
|
171
|
-
* @param {Cacheable | undefined} value - The cacheable instance to set. If set to undefined, caching will be disabled.
|
|
172
|
-
*/
|
|
173
|
-
set cache(value: Cacheable | undefined);
|
|
174
|
-
/**
|
|
175
|
-
* Get the cacheable memory instance
|
|
176
|
-
* @returns {CacheableMemory | undefined} - The cacheable memory instance or undefined if caching is disabled
|
|
177
|
-
*/
|
|
178
|
-
get cacheSync(): CacheableMemory | undefined;
|
|
179
|
-
/**
|
|
180
|
-
* Set the cacheable memory instance
|
|
181
|
-
* @param {CacheableMemory | undefined} value - The cacheable memory instance to set. If set to undefined, caching will be disabled.
|
|
182
|
-
*/
|
|
183
|
-
set cacheSync(value: CacheableMemory | undefined);
|
|
184
|
-
/**
|
|
185
|
-
* Get the Engine Mappings. This is used to map file extensions to engines
|
|
186
|
-
* @returns {EngineMap}
|
|
187
|
-
*/
|
|
188
|
-
get mappings(): EngineMap;
|
|
189
|
-
/**
|
|
190
|
-
* Get the EJS Engine
|
|
191
|
-
* @returns {EJS}
|
|
192
|
-
*/
|
|
193
|
-
get ejs(): EJS;
|
|
194
|
-
/**
|
|
195
|
-
* Get the Markdown Engine
|
|
196
|
-
* @returns {Markdown}
|
|
197
|
-
*/
|
|
198
|
-
get markdown(): Markdown;
|
|
199
|
-
/**
|
|
200
|
-
* Get the Pug Engine
|
|
201
|
-
* @returns {Pug}
|
|
202
|
-
*/
|
|
203
|
-
get pug(): Pug;
|
|
204
|
-
/**
|
|
205
|
-
* Get the Nunjucks Engine
|
|
206
|
-
* @returns {Nunjucks}
|
|
207
|
-
*/
|
|
208
|
-
get nunjucks(): Nunjucks;
|
|
209
|
-
/**
|
|
210
|
-
* Get the Handlebars Engine
|
|
211
|
-
* @returns {Handlebars}
|
|
212
|
-
*/
|
|
213
|
-
get handlebars(): Handlebars;
|
|
214
|
-
/**
|
|
215
|
-
* Get the Liquid Engine
|
|
216
|
-
* @returns {Liquid}
|
|
217
|
-
*/
|
|
218
|
-
get liquid(): Liquid;
|
|
219
|
-
/**
|
|
220
|
-
* Asynchronously render a template source with data using the specified engine
|
|
221
|
-
* @param {string} source - The template source string to render
|
|
222
|
-
* @param {Record<string, unknown>} [data] - Data object to pass to the template engine
|
|
223
|
-
* @param {string} [engineName] - Name of the engine to use (e.g., 'ejs', 'pug'). Defaults to defaultEngine
|
|
224
|
-
* @param {string} [rootTemplatePath] - Root directory path for template includes/partials resolution
|
|
225
|
-
* @param {string} [filePathOutput] - Optional file path to write the rendered output to
|
|
226
|
-
* @returns {Promise<string>} The rendered template output as a string
|
|
227
|
-
* @example
|
|
228
|
-
* const result = await ecto.render('<%= name %>', { name: 'World' }, 'ejs');
|
|
229
|
-
*/
|
|
230
|
-
render(source: string, data?: Record<string, unknown>, engineName?: string, rootTemplatePath?: string, filePathOutput?: string): Promise<string>;
|
|
231
|
-
/**
|
|
232
|
-
* Synchronously render a template source with data using the specified engine
|
|
233
|
-
* @param {string} source - The template source string to render
|
|
234
|
-
* @param {Record<string, unknown>} [data] - Data object to pass to the template engine
|
|
235
|
-
* @param {string} [engineName] - Name of the engine to use (e.g., 'ejs', 'pug'). Defaults to defaultEngine
|
|
236
|
-
* @param {string} [rootTemplatePath] - Root directory path for template includes/partials resolution
|
|
237
|
-
* @param {string} [filePathOutput] - Optional file path to write the rendered output to
|
|
238
|
-
* @returns {string} The rendered template output as a string
|
|
239
|
-
* @example
|
|
240
|
-
* const result = ecto.renderSync('<%= name %>', { name: 'World' }, 'ejs');
|
|
241
|
-
*/
|
|
242
|
-
renderSync(source: string, data?: Record<string, unknown>, engineName?: string, rootTemplatePath?: string, filePathOutput?: string): string;
|
|
243
|
-
/**
|
|
244
|
-
* Run hooks synchronously for a specific event
|
|
245
|
-
* @param {string} event - The event name
|
|
246
|
-
* @param {unknown[]} args - Arguments to pass to the hooks
|
|
247
|
-
* @private
|
|
248
|
-
*/
|
|
249
|
-
private runHooksSync;
|
|
250
|
-
/**
|
|
251
|
-
* Asynchronously render a template from a file path
|
|
252
|
-
* @param {string} filePath - Path to the template file to render
|
|
253
|
-
* @param {Record<string, unknown>} [data] - Data object to pass to the template engine
|
|
254
|
-
* @param {string} [rootTemplatePath] - Root directory for template includes. Defaults to file's directory
|
|
255
|
-
* @param {string} [filePathOutput] - Optional file path to write the rendered output to
|
|
256
|
-
* @param {string} [engineName] - Engine to use. If not specified, determined from file extension
|
|
257
|
-
* @returns {Promise<string>} The rendered template output as a string
|
|
258
|
-
* @example
|
|
259
|
-
* const result = await ecto.renderFromFile('./templates/index.ejs', { title: 'Home' });
|
|
260
|
-
*/
|
|
261
|
-
renderFromFile(filePath: string, data?: Record<string, unknown>, rootTemplatePath?: string, filePathOutput?: string, engineName?: string): Promise<string>;
|
|
262
|
-
/**
|
|
263
|
-
* Synchronously render a template from a file path
|
|
264
|
-
* @param {string} filePath - Path to the template file to render
|
|
265
|
-
* @param {Record<string, unknown>} [data] - Data object to pass to the template engine
|
|
266
|
-
* @param {string} [rootTemplatePath] - Root directory for template includes. Defaults to file's directory
|
|
267
|
-
* @param {string} [filePathOutput] - Optional file path to write the rendered output to
|
|
268
|
-
* @param {string} [engineName] - Engine to use. If not specified, determined from file extension
|
|
269
|
-
* @returns {string} The rendered template output as a string
|
|
270
|
-
* @example
|
|
271
|
-
* const result = ecto.renderFromFileSync('./templates/index.ejs', { title: 'Home' });
|
|
272
|
-
*/
|
|
273
|
-
renderFromFileSync(filePath: string, data?: Record<string, unknown>, rootTemplatePath?: string, filePathOutput?: string, engineName?: string): string;
|
|
274
|
-
/**
|
|
275
|
-
* Asynchronously ensure that the directory path for a file exists, creating it if necessary
|
|
276
|
-
* @param {string} path - The full file path (directories will be extracted from this)
|
|
277
|
-
* @returns {Promise<void>}
|
|
278
|
-
* @example
|
|
279
|
-
* await ecto.ensureFilePath('/path/to/file.txt');
|
|
280
|
-
*/
|
|
281
|
-
ensureFilePath(path: string): Promise<void>;
|
|
282
|
-
/**
|
|
283
|
-
* Synchronously ensure that the directory path for a file exists, creating it if necessary
|
|
284
|
-
* @param {string} path - The full file path (directories will be extracted from this)
|
|
285
|
-
* @returns {void}
|
|
286
|
-
* @example
|
|
287
|
-
* ecto.ensureFilePathSync('/path/to/file.txt');
|
|
288
|
-
*/
|
|
289
|
-
ensureFilePathSync(path: string): void;
|
|
290
|
-
/**
|
|
291
|
-
* Determine the appropriate template engine based on a file's extension
|
|
292
|
-
* @param {string} filePath - The file path to analyze
|
|
293
|
-
* @returns {string} The engine name (e.g., 'ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid')
|
|
294
|
-
* @example
|
|
295
|
-
* const engine = ecto.getEngineByFilePath('template.ejs'); // Returns 'ejs'
|
|
296
|
-
*/
|
|
297
|
-
getEngineByFilePath(filePath: string): string;
|
|
298
|
-
/**
|
|
299
|
-
* Asynchronously find a template file in a directory by name, regardless of extension
|
|
300
|
-
* @param {string} path - Directory path to search in
|
|
301
|
-
* @param {string} templateName - Template name without extension
|
|
302
|
-
* @returns {Promise<string>} Full path to the found template file, or empty string if not found
|
|
303
|
-
* @example
|
|
304
|
-
* const templatePath = await ecto.findTemplateWithoutExtension('./templates', 'index');
|
|
305
|
-
*/
|
|
306
|
-
findTemplateWithoutExtension(path: string, templateName: string): Promise<string>;
|
|
307
|
-
/**
|
|
308
|
-
* Synchronously find a template file in a directory by name, regardless of extension
|
|
309
|
-
* @param {string} path - Directory path to search in
|
|
310
|
-
* @param {string} templateName - Template name without extension
|
|
311
|
-
* @returns {string} Full path to the found template file, or empty string if not found
|
|
312
|
-
* @example
|
|
313
|
-
* const templatePath = ecto.findTemplateWithoutExtensionSync('./templates', 'index');
|
|
314
|
-
*/
|
|
315
|
-
findTemplateWithoutExtensionSync(path: string, templateName: string): string;
|
|
316
|
-
/**
|
|
317
|
-
* Check if the given engine name is valid and registered in Ecto
|
|
318
|
-
* @param {string} [engineName] - The engine name to validate
|
|
319
|
-
* @returns {boolean} True if the engine is valid and registered, false otherwise
|
|
320
|
-
* @example
|
|
321
|
-
* const isValid = ecto.isValidEngine('ejs'); // Returns true
|
|
322
|
-
*/
|
|
323
|
-
isValidEngine(engineName?: string): boolean;
|
|
324
|
-
/**
|
|
325
|
-
* Detect the template engine from a template string by analyzing its syntax
|
|
326
|
-
* @param {string} source - The template source string to analyze
|
|
327
|
-
* @returns {string} The detected engine name ('ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid') or the default engine
|
|
328
|
-
* @example
|
|
329
|
-
* const engine = ecto.detectEngine('<%= name %>'); // Returns 'ejs'
|
|
330
|
-
* const engine2 = ecto.detectEngine('{{name}}'); // Returns 'handlebars' or 'liquid'
|
|
331
|
-
* const engine3 = ecto.detectEngine('# Heading'); // Returns 'markdown'
|
|
332
|
-
* const engine4 = ecto.detectEngine('plain text'); // Returns defaultEngine (e.g., 'ejs')
|
|
333
|
-
*/
|
|
334
|
-
detectEngine(source: string): string;
|
|
335
|
-
/**
|
|
336
|
-
* Register all engine mappings between engine names and file extensions
|
|
337
|
-
* @returns {void}
|
|
338
|
-
* @private
|
|
339
|
-
*/
|
|
340
|
-
registerEngineMappings(): void;
|
|
341
|
-
/**
|
|
342
|
-
* Get the render engine instance by name
|
|
343
|
-
* @param {string} engineName - The name of the engine to retrieve
|
|
344
|
-
* @returns {EngineInterface} The engine instance (defaults to EJS if not found)
|
|
345
|
-
* @example
|
|
346
|
-
* const engine = ecto.getRenderEngine('pug');
|
|
347
|
-
*/
|
|
348
|
-
getRenderEngine(engineName: string): EngineInterface;
|
|
349
|
-
/**
|
|
350
|
-
* Check if the source content contains front matter (YAML metadata)
|
|
351
|
-
* @param {string} source - The source content to check
|
|
352
|
-
* @returns {boolean} True if front matter is present, false otherwise
|
|
353
|
-
* @example
|
|
354
|
-
* const hasFM = ecto.hasFrontMatter('---\ntitle: Test\n---\nContent');
|
|
355
|
-
*/
|
|
356
|
-
hasFrontMatter(source: string): boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Extract front matter data from the source content
|
|
359
|
-
* @param {string} source - The source content containing front matter
|
|
360
|
-
* @returns {Record<string, unknown>} Parsed front matter as an object
|
|
361
|
-
* @example
|
|
362
|
-
* const data = ecto.getFrontMatter('---\ntitle: Test\n---\nContent');
|
|
363
|
-
*/
|
|
364
|
-
getFrontMatter(source: string): Record<string, unknown>;
|
|
365
|
-
/**
|
|
366
|
-
* Set or replace front matter in the source content
|
|
367
|
-
* @param {string} source - The source content
|
|
368
|
-
* @param {Record<string, unknown>} data - The front matter data to set
|
|
369
|
-
* @returns {string} The source content with updated front matter
|
|
370
|
-
* @example
|
|
371
|
-
* const updated = ecto.setFrontMatter('Content', { title: 'New Title' });
|
|
372
|
-
*/
|
|
373
|
-
setFrontMatter(source: string, data: Record<string, unknown>): string;
|
|
374
|
-
/**
|
|
375
|
-
* Remove front matter from the source content, returning only the body
|
|
376
|
-
* @param {string} source - The source content with front matter
|
|
377
|
-
* @returns {string} The source content without front matter
|
|
378
|
-
* @example
|
|
379
|
-
* const body = ecto.removeFrontMatter('---\ntitle: Test\n---\nContent');
|
|
380
|
-
*/
|
|
381
|
-
removeFrontMatter(source: string): string;
|
|
382
|
-
/**
|
|
383
|
-
* Write content to a file asynchronously, creating directories if needed
|
|
384
|
-
* @private
|
|
385
|
-
* @param {string} [filePath] - The path to write the file to
|
|
386
|
-
* @param {string} [source] - The content to write to the file
|
|
387
|
-
* @returns {Promise<void>}
|
|
388
|
-
*/
|
|
389
|
-
private writeFile;
|
|
390
|
-
/**
|
|
391
|
-
* Write content to a file synchronously, creating directories if needed
|
|
392
|
-
* @private
|
|
393
|
-
* @param {string} [filePath] - The path to write the file to
|
|
394
|
-
* @param {string} [source] - The content to write to the file
|
|
395
|
-
* @returns {void}
|
|
396
|
-
*/
|
|
397
|
-
private writeFileSync;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
export { BaseEngine, EJS, Ecto, EctoEvents, type EctoOptions, type EngineInterface, Handlebars, Liquid, Markdown, Nunjucks, Pug, type RenderContext, type RenderResult };
|