@financial-times/dotcom-server-handlebars 7.3.0 → 7.3.2

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.
Files changed (33) hide show
  1. package/dist/node/PageKitHandlebars.d.ts +46 -0
  2. package/dist/node/findPartialFiles.d.ts +2 -0
  3. package/dist/node/helpers/array.d.ts +1 -0
  4. package/dist/node/helpers/capture.d.ts +2 -0
  5. package/dist/node/helpers/concat.d.ts +1 -0
  6. package/dist/node/helpers/dateformat.d.ts +1 -0
  7. package/dist/node/helpers/encode.d.ts +1 -0
  8. package/dist/node/helpers/ifAll.d.ts +1 -0
  9. package/dist/node/helpers/ifEquals.d.ts +1 -0
  10. package/dist/node/helpers/ifEqualsSome.d.ts +1 -0
  11. package/dist/node/helpers/ifSome.d.ts +1 -0
  12. package/dist/node/helpers/json.d.ts +1 -0
  13. package/dist/node/helpers/renderReactComponent.d.ts +3 -0
  14. package/dist/node/helpers/resize.d.ts +1 -0
  15. package/dist/node/helpers/slice.d.ts +1 -0
  16. package/dist/node/helpers/unlessAll.d.ts +1 -0
  17. package/dist/node/helpers/unlessEquals.d.ts +1 -0
  18. package/dist/node/helpers/unlessSome.d.ts +1 -0
  19. package/dist/node/helpers.d.ts +16 -0
  20. package/dist/node/index.d.ts +3 -0
  21. package/dist/node/loadFileContents.d.ts +1 -0
  22. package/dist/tsconfig.tsbuildinfo +3320 -0
  23. package/package.json +7 -4
  24. package/src/__test__/HandlebarsRenderer.spec.ts +99 -0
  25. package/src/__test__/__fixtures__/components/DefaultExportComponentCJS.js +5 -0
  26. package/src/__test__/__fixtures__/components/DefaultExportComponentES.tsx +5 -0
  27. package/src/__test__/__fixtures__/components/NamedExportComponentCJS.js +5 -0
  28. package/src/__test__/__fixtures__/components/NamedExportComponentES.tsx +5 -0
  29. package/src/__test__/__fixtures__/views/partials/content.hbs +1 -0
  30. package/src/__test__/__fixtures__/views/partials/partial.hbs +1 -0
  31. package/src/__test__/__fixtures__/views/partials/wrapper.hbs +3 -0
  32. package/src/__test__/__fixtures__/views/view.hbs +4 -0
  33. package/src/__test__/helpers.spec.ts +341 -0
@@ -0,0 +1,46 @@
1
+ import Handlebars, { HelperDelegate, TemplateDelegate } from 'handlebars';
2
+ import { TRenderCallback, TPartialTemplates, TFilePaths } from './types';
3
+ export declare type TPageKitHandlebarsOptions = {
4
+ /**
5
+ * An instance of Handlebars to use.
6
+ * @default require('handlebars')
7
+ */
8
+ handlebars?: typeof Handlebars;
9
+ /**
10
+ * Current working directory.
11
+ * @default process.cwd()
12
+ */
13
+ rootDirectory?: string;
14
+ /**
15
+ * Additional helper functions to register with Handlebars.
16
+ * @default {}
17
+ */
18
+ helpers?: {
19
+ [key: string]: HelperDelegate;
20
+ };
21
+ /**
22
+ * Partial templates to register with Handlebars.
23
+ * @default {}
24
+ */
25
+ partials?: TPartialTemplates;
26
+ /**
27
+ * A list of directories and patterns used to dynamically find and load partial template files.
28
+ * @default { './views/partials': '**\/*.{hbs,html}' }
29
+ */
30
+ partialPaths?: TFilePaths;
31
+ /**
32
+ * Enable caching of template files to reduce filesystem I/O
33
+ * @default process.env.NODE_ENV !== 'development
34
+ */
35
+ cache?: boolean;
36
+ };
37
+ export declare class PageKitHandlebars {
38
+ options: TPageKitHandlebarsOptions;
39
+ engine: this['renderView'];
40
+ private cache;
41
+ constructor(userOptions?: TPageKitHandlebarsOptions);
42
+ loadPartials(): TPartialTemplates;
43
+ loadTemplate(filePath: string): TemplateDelegate;
44
+ render(template: string | TemplateDelegate, templateContext: any): string;
45
+ renderView(templatePath: string, templateContext: any, callback: TRenderCallback): void;
46
+ }
@@ -0,0 +1,2 @@
1
+ import { TFilePaths } from './types';
2
+ export default function loadPartialFiles(cwd: string, partialPaths: TFilePaths): TFilePaths;
@@ -0,0 +1 @@
1
+ export default function array(...args: any[]): any[];
@@ -0,0 +1,2 @@
1
+ import { HelperOptions } from 'handlebars';
2
+ export default function capture(name: string, options: HelperOptions): void;
@@ -0,0 +1 @@
1
+ export default function concat(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function dateformat(...args: any[]): any;
@@ -0,0 +1 @@
1
+ export default function encode(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function ifAll(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function ifEquals(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function ifEqualsSome(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function ifSome(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function json(...args: any[]): string;
@@ -0,0 +1,3 @@
1
+ export default function renderReactComponent({ hash }: {
2
+ hash: any;
3
+ }): any;
@@ -0,0 +1 @@
1
+ export default function resize(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function slice(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function unlessAll(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function unlessEquals(...args: any[]): string;
@@ -0,0 +1 @@
1
+ export default function unlessSome(...args: any[]): string;
@@ -0,0 +1,16 @@
1
+ export { default as array } from './helpers/array';
2
+ export { default as capture } from './helpers/capture';
3
+ export { default as concat } from './helpers/concat';
4
+ export { default as dateformat } from './helpers/dateformat';
5
+ export { default as encode } from './helpers/encode';
6
+ export { default as ifAll } from './helpers/ifAll';
7
+ export { default as ifEquals } from './helpers/ifEquals';
8
+ export { default as ifEqualsSome } from './helpers/ifEqualsSome';
9
+ export { default as ifSome } from './helpers/ifSome';
10
+ export { default as json } from './helpers/json';
11
+ export { default as renderReactComponent } from './helpers/renderReactComponent';
12
+ export { default as resize } from './helpers/resize';
13
+ export { default as slice } from './helpers/slice';
14
+ export { default as unlessAll } from './helpers/unlessAll';
15
+ export { default as unlessEquals } from './helpers/unlessEquals';
16
+ export { default as unlessSome } from './helpers/unlessSome';
@@ -0,0 +1,3 @@
1
+ import * as helpers from './helpers';
2
+ export * from './PageKitHandlebars';
3
+ export { helpers };
@@ -0,0 +1 @@
1
+ export default function loadFileContents(filePath: string): string;