@brand-map/generator 0.1.0 → 0.1.1

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 CHANGED
@@ -206,10 +206,6 @@ The generator maintains a context object with the following structure:
206
206
  {
207
207
  templates: Record<string, TemplateData>; // Loaded templates
208
208
  data: unknown; // Your data (object or array)
209
- rendered: Array<{
210
- // Rendered files
211
- path: string;
212
- content: string;
213
- }>;
209
+ rendered: Array<{ path: string; content: string }>; // Rendered files
214
210
  }
215
211
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brand-map/generator",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Renderer",
5
5
  "license": "MIT",
6
6
  "author": "Brand-Map Team",
@@ -7,7 +7,13 @@ export type TemplateData = {
7
7
  content: string;
8
8
  };
9
9
 
10
- export async function loadTemplates(teamplatesPath: string): Promise<(ctx: Record<string, any>) => { templates: Record<string, TemplateData> }> {
10
+ export async function loadTemplates(
11
+ teamplatesPath: string,
12
+ config?: {
13
+ filters?: (template: any) => boolean;
14
+ // | ((template: any) => boolean)[]
15
+ },
16
+ ): Promise<(ctx: Record<string, any>) => { templates: Record<string, TemplateData> }> {
11
17
  if (!teamplatesPath || typeof teamplatesPath !== "string") {
12
18
  throw new Error(`Invalid templates path provided. Try string`);
13
19
  }
@@ -16,11 +22,17 @@ export async function loadTemplates(teamplatesPath: string): Promise<(ctx: Recor
16
22
 
17
23
  const resolvedPath = resolve(teamplatesPath);
18
24
 
25
+ const filters = config?.filters;
26
+
19
27
  for await (const templatePath of walkDir(resolvedPath)) {
20
28
  if (path.basename(templatePath).startsWith("_")) {
21
29
  continue;
22
30
  }
23
31
 
32
+ if (filters && !filters(teamplatesPath)) {
33
+ continue;
34
+ }
35
+
24
36
  const relative = path.relative(resolvedPath, templatePath).replace(".hbs", "").replace(".vto", "");
25
37
 
26
38
  const contentRaw = await readFile(path.resolve(resolvedPath, templatePath));