@trustme24/flext 1.0.4 → 1.1.0
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/dist/errors.d.ts +3 -0
- package/dist/index.cjs +18 -15
- package/dist/index.d.ts +7 -14
- package/dist/index.js +9 -9
- package/dist/lib.d.ts +36 -4
- package/dist/types.d.ts +15 -0
- package/package.json +3 -2
package/dist/lib.d.ts
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AST } from '@handlebars/parser';
|
|
2
|
+
import { Obj, Macro, MacroParam, DataModelNode, DataModel } from './types';
|
|
3
|
+
import Handlebars, { TemplateDelegate } from 'handlebars';
|
|
4
|
+
export type CollectorFilterHandler<T = any> = (val?: T) => boolean;
|
|
5
|
+
export declare const DEFAULT_MODEL_DEPTH = 10;
|
|
6
|
+
export declare class HandlebarsCollector<T = any> extends Handlebars.Visitor {
|
|
7
|
+
data: T[];
|
|
8
|
+
match: CollectorFilterHandler<T>;
|
|
9
|
+
constructor(filter?: CollectorFilterHandler<T>);
|
|
10
|
+
onCollect(val: T): void;
|
|
11
|
+
setMatchHandler(val: CollectorFilterHandler<T>): this;
|
|
12
|
+
setAst(ast: AST.Program): this;
|
|
13
|
+
collect(ast: AST.Program): T[];
|
|
14
|
+
}
|
|
15
|
+
export declare function isObject(val: any): boolean;
|
|
3
16
|
export declare function has(obj: Obj, key: string): boolean;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function getHtml(template: TemplateDelegate, data?: Obj, helpers?: Obj): string;
|
|
17
|
+
export declare function audit(val: any): string;
|
|
6
18
|
export declare function defineModule(options?: any): any;
|
|
19
|
+
export declare function unique<T = any>(arr: T[]): T[];
|
|
20
|
+
export declare function getAst(val: string): AST.Program;
|
|
21
|
+
export declare function getTemplate(val: string | AST.Program): TemplateDelegate;
|
|
22
|
+
export declare function getHtml(template: TemplateDelegate, data?: Obj, helpers?: Obj): string;
|
|
23
|
+
export declare function getPaths(ast: AST.Program): string[];
|
|
24
|
+
export declare function pathToDataModelNode(path: string, depth?: number): DataModelNode;
|
|
25
|
+
export declare function pathToDataModel(path: string, depth?: number): DataModel;
|
|
26
|
+
export declare function getDataModel(ast: AST.Program): DataModel;
|
|
27
|
+
export declare function getMacroParam(val: string): MacroParam | null;
|
|
28
|
+
export declare function getMacroParams(val: string, doWarn?: boolean): MacroParam[];
|
|
29
|
+
export declare function getMacros(ast: AST.Program, doWarn?: boolean): Macro[];
|
|
30
|
+
export declare class RegexHelper {
|
|
31
|
+
static macro: RegExp;
|
|
32
|
+
static macroParam: RegExp;
|
|
33
|
+
static macroNamedParam: RegExp;
|
|
34
|
+
static macroSimpleParam: RegExp;
|
|
35
|
+
}
|
|
36
|
+
export declare class FilterHelper {
|
|
37
|
+
static macro(val: string): boolean;
|
|
38
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
1
|
export type Obj<T = any> = Record<string, T>;
|
|
2
|
+
export type DataModelNode = {
|
|
3
|
+
name: string;
|
|
4
|
+
$?: DataModelNode[];
|
|
5
|
+
};
|
|
6
|
+
export type DataModel = DataModelNode & {
|
|
7
|
+
addPath: (path: string, depth?: number) => void;
|
|
8
|
+
};
|
|
9
|
+
export type MacroParam = {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string | null;
|
|
12
|
+
};
|
|
13
|
+
export type Macro = {
|
|
14
|
+
name: string;
|
|
15
|
+
params: MacroParam[];
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustme24/flext",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A Powerful Templating Engine",
|
|
5
5
|
"keywords": ["templates", "templating engine", "modular templates", "handlebars"],
|
|
6
6
|
"type": "commonjs",
|
|
@@ -29,10 +29,11 @@
|
|
|
29
29
|
"@babel/core": "^7.26.10",
|
|
30
30
|
"@babel/preset-env": "^7.26.9",
|
|
31
31
|
"@babel/preset-typescript": "^7.26.0",
|
|
32
|
+
"@handlebars/parser": "^2.2.0",
|
|
32
33
|
"@tailwindcss/cli": "^4.1.11",
|
|
33
34
|
"@types/minimist": "^1.2.5",
|
|
34
35
|
"@types/node": "^22.14.0",
|
|
35
|
-
"esbuild": "^0.25.
|
|
36
|
+
"esbuild": "^0.25.6",
|
|
36
37
|
"esbuild-plugin-import-glob": "^0.1.1",
|
|
37
38
|
"tailwindcss": "^4.1.11",
|
|
38
39
|
"tsc-alias": "^1.8.11",
|