@jaredwray/fumanchu 3.0.1 → 3.0.3
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 +2 -2
- package/dist/index.d.ts +18 -1
- package/dist/index.js +25 -3
- package/package.json +13 -10
package/README.md
CHANGED
|
@@ -27,8 +27,8 @@ We plan to make significant changes over time with this project such as the foll
|
|
|
27
27
|
Because of the complexity in the legacy helpers library we have moved to exporting the libraries and a helper function to make it easier to use. Here are the exports:
|
|
28
28
|
|
|
29
29
|
- `handlebars` - This is an instance of handlebars library without any helpers. It is the same as calling `Handlebars.create()`
|
|
30
|
-
- `helpers` - This is a function that takes an object with a `handlebars` key and adds all the helpers to the handlebars instance. This is the same as calling `helpers({ handlebars: handlebars })`
|
|
31
|
-
- `createHandlebars` - This is an async function that returns a handlebars instance with all the helpers added. This is the same as calling `helpers({ handlebars: handlebars })` but async.
|
|
30
|
+
- `helpers` - This is a function that takes an object with a `handlebars` key and adds all the helpers to the handlebars instance. This is the same as calling `helpers({ handlebars: handlebars }, { ..options })`
|
|
31
|
+
- `createHandlebars` - This is an async function that returns a handlebars instance with all the helpers added. This is the same as calling `helpers({ handlebars: handlebars }, { ..options })` but async.
|
|
32
32
|
- `Handlebars` - This is the handlebars library itself. It is the same as calling `require('handlebars')`
|
|
33
33
|
|
|
34
34
|
Please see the examples below for how to use the library.
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,23 @@ type HelperFilter = {
|
|
|
9
9
|
category?: string;
|
|
10
10
|
compatibility?: HelperRegistryCompatibility;
|
|
11
11
|
};
|
|
12
|
+
type Helper = {
|
|
13
|
+
name: string;
|
|
14
|
+
category: string;
|
|
15
|
+
compatibility?: HelperRegistryCompatibility;
|
|
16
|
+
fn: ((...arguments_: any[]) => string);
|
|
17
|
+
};
|
|
18
|
+
declare class HelperRegistry {
|
|
19
|
+
private readonly _helpers;
|
|
20
|
+
constructor();
|
|
21
|
+
init(): void;
|
|
22
|
+
register(helper: Helper): boolean;
|
|
23
|
+
registerHelpers(helpers: Helper[]): void;
|
|
24
|
+
has(name: string): boolean;
|
|
25
|
+
filter(filter: HelperFilter): Helper[];
|
|
26
|
+
loadHandlebars(handlebars: any): void;
|
|
27
|
+
swapHelpers(handlebars: any): void;
|
|
28
|
+
}
|
|
12
29
|
|
|
13
30
|
/**
|
|
14
31
|
* Handlebars library not initiated with helpers
|
|
@@ -61,4 +78,4 @@ type FumanchuOptions = {
|
|
|
61
78
|
*/
|
|
62
79
|
declare function fumanchu(options?: FumanchuOptions): typeof HandlebarsLib;
|
|
63
80
|
|
|
64
|
-
export { type FumanchuCachingOptions, type FumanchuOptions, Handlebars, createHandlebars, fumanchu, handlebars, helpers };
|
|
81
|
+
export { type FumanchuCachingOptions, type FumanchuOptions, Handlebars, type HelperFilter, HelperRegistry, createHandlebars, fumanchu, handlebars, helpers };
|
package/dist/index.js
CHANGED
|
@@ -2031,24 +2031,45 @@ var require_helpers = __commonJS({
|
|
|
2031
2031
|
});
|
|
2032
2032
|
|
|
2033
2033
|
// src/index.ts
|
|
2034
|
-
var
|
|
2035
|
-
__export(
|
|
2034
|
+
var index_exports = {};
|
|
2035
|
+
__export(index_exports, {
|
|
2036
2036
|
Handlebars: () => Handlebars,
|
|
2037
|
+
HelperRegistry: () => HelperRegistry,
|
|
2037
2038
|
createHandlebars: () => createHandlebars,
|
|
2038
2039
|
fumanchu: () => fumanchu,
|
|
2039
2040
|
handlebars: () => handlebars,
|
|
2040
2041
|
helpers: () => helpers2
|
|
2041
2042
|
});
|
|
2042
|
-
module.exports = __toCommonJS(
|
|
2043
|
+
module.exports = __toCommonJS(index_exports);
|
|
2043
2044
|
var HandlebarsLib = __toESM(require("handlebars"));
|
|
2044
2045
|
|
|
2045
2046
|
// src/helpers/date.ts
|
|
2047
|
+
var import_chrono_node = require("chrono-node");
|
|
2048
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
2046
2049
|
var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
2050
|
+
var date = (humanReadableDate, formatString) => {
|
|
2051
|
+
const parsedDate = (0, import_chrono_node.parseDate)(humanReadableDate);
|
|
2052
|
+
if (!parsedDate) {
|
|
2053
|
+
throw new Error(`Unable to parse date: ${humanReadableDate}`);
|
|
2054
|
+
}
|
|
2055
|
+
return (0, import_dayjs.default)(parsedDate).format(formatString);
|
|
2056
|
+
};
|
|
2047
2057
|
var helpers = [
|
|
2048
2058
|
{
|
|
2049
2059
|
name: "year",
|
|
2050
2060
|
category: "date",
|
|
2051
2061
|
fn: year
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
name: "date",
|
|
2065
|
+
category: "date",
|
|
2066
|
+
fn: date
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
/* Adding this in for legacy support */
|
|
2070
|
+
name: "moment",
|
|
2071
|
+
category: "date",
|
|
2072
|
+
fn: date
|
|
2052
2073
|
}
|
|
2053
2074
|
];
|
|
2054
2075
|
|
|
@@ -2116,6 +2137,7 @@ function fumanchu(options) {
|
|
|
2116
2137
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2117
2138
|
0 && (module.exports = {
|
|
2118
2139
|
Handlebars,
|
|
2140
|
+
HelperRegistry,
|
|
2119
2141
|
createHandlebars,
|
|
2120
2142
|
fumanchu,
|
|
2121
2143
|
handlebars,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaredwray/fumanchu",
|
|
3
3
|
"description": "Handlebars + Helpers = Fumanchu",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"homepage": "https://github.com/jaredwray/fumanchu",
|
|
6
6
|
"author": "Jared Wray (me@jaredwray.com)",
|
|
7
7
|
"source": "dist/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "xo --fix && vitest run --coverage",
|
|
12
12
|
"test:ci": "xo && vitest run --coverage",
|
|
13
|
+
"test:all": "npm run test && npm run test:legacy",
|
|
13
14
|
"test:legacy": "npm run build && c8 mocha",
|
|
14
15
|
"test:legacy:ci": "npm run build && c8 --reporter=lcov mocha",
|
|
15
16
|
"build": "rimraf ./dist && tsup ./src/index.ts --format cjs --dts --clean",
|
|
@@ -58,10 +59,12 @@
|
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"arr-flatten": "^1.1.0",
|
|
60
61
|
"array-sort": "^1.0.0",
|
|
61
|
-
"cacheable": "^1.8.
|
|
62
|
+
"cacheable": "^1.8.7",
|
|
63
|
+
"chrono-node": "^2.7.7",
|
|
62
64
|
"create-frame": "^1.0.0",
|
|
65
|
+
"dayjs": "^1.11.13",
|
|
63
66
|
"define-property": "^2.0.2",
|
|
64
|
-
"ent": "^2.2.
|
|
67
|
+
"ent": "^2.2.2",
|
|
65
68
|
"extend-shallow": "^3.0.2",
|
|
66
69
|
"for-in": "^1.0.2",
|
|
67
70
|
"for-own": "^1.0.0",
|
|
@@ -73,7 +76,7 @@
|
|
|
73
76
|
"handlebars-utils": "^1.0.6",
|
|
74
77
|
"has-value": "^2.0.2",
|
|
75
78
|
"helper-date": "^1.0.1",
|
|
76
|
-
"highlight.js": "^11.
|
|
79
|
+
"highlight.js": "^11.11.1",
|
|
77
80
|
"html-tag": "^2.0.0",
|
|
78
81
|
"is-even": "^1.0.0",
|
|
79
82
|
"is-glob": "^4.0.3",
|
|
@@ -90,10 +93,10 @@
|
|
|
90
93
|
"year": "^0.2.1"
|
|
91
94
|
},
|
|
92
95
|
"devDependencies": {
|
|
93
|
-
"@vitest/coverage-v8": "^
|
|
94
|
-
"c8": "^10.1.
|
|
96
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
97
|
+
"c8": "^10.1.3",
|
|
95
98
|
"chai": "^4.3.10",
|
|
96
|
-
"docula": "^0.9.
|
|
99
|
+
"docula": "^0.9.6",
|
|
97
100
|
"engine-handlebars": "^1.1.0",
|
|
98
101
|
"lodash": "^4.17.21",
|
|
99
102
|
"mocha": "^10.8.2",
|
|
@@ -102,9 +105,9 @@
|
|
|
102
105
|
"templates": "^1.2.9",
|
|
103
106
|
"tsup": "^8.3.5",
|
|
104
107
|
"typecript": "^0.0.1-security",
|
|
105
|
-
"typescript": "^5.
|
|
106
|
-
"vitest": "^
|
|
107
|
-
"xo": "^0.
|
|
108
|
+
"typescript": "^5.7.3",
|
|
109
|
+
"vitest": "^3.0.0",
|
|
110
|
+
"xo": "^0.60.0"
|
|
108
111
|
},
|
|
109
112
|
"xo": {
|
|
110
113
|
"ignores": [
|