@nitro/app 9.4.2 → 10.0.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.
@@ -31,12 +31,22 @@ Object.keys(files).forEach((key) => {
31
31
  const helperTagFactory = require(files[key]);
32
32
 
33
33
  // expose helper as custom tag
34
- /* eslint-disable-next-line */
35
- Twig.extend(function (Twig) {
36
- Twig.exports.extendTag(helperTagFactory(Twig));
34
+ Twig.extend((TwigInstance) => {
35
+ const result = helperTagFactory(TwigInstance);
36
+
37
+ // if the helper returned a tag (i.e., a config object), register it
38
+ if (result && result.type && result.parse) {
39
+ TwigInstance.exports.extendTag(result);
40
+ }
41
+
42
+ // if it didn’t return anything, it’s probably a filter or global setup
43
+ // Nothing else to do here
37
44
  });
38
45
  });
39
46
 
47
+ // register t filter
48
+ require('./filters/t')(Twig);
49
+
40
50
  // eslint-disable-next-line
41
51
  Twig.renderWithLayout = (viewPath, options, fn) => {
42
52
  const layoutPath = path.join(options.settings.views, `${options.layout}.${options.settings['view engine']}`);
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Simple Twig Translation Filter
5
+ *
6
+ * @dependency: https://www.npmjs.com/package/i18next
7
+ * http://i18next.com/
8
+ *
9
+ * @examples
10
+ * default translation file in project/locales/default/translation.json
11
+ *
12
+ * {{ 'test.example.string'|t }}
13
+ * {{ 'test.example.interpolation'|t({ name: 'developer' }) }}
14
+ *
15
+ * It should be also possible to use other translation features from i18next (http://i18next.com/translate/)
16
+ */
17
+ const i18next = require('i18next');
18
+
19
+ module.exports = function registerTranslationFilter (Twig) {
20
+ // Register the `t` filter
21
+ Twig.extendFilter('t', (value, args) => {
22
+ try {
23
+ // Twig passes filter args as an array: args[0] is your options object
24
+ const options = args && args[0] ? args[0] : {};
25
+ return i18next.t(value, options);
26
+ } catch (e) {
27
+ console.error('Translation error:', e);
28
+ return value;
29
+ }
30
+ });
31
+ };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * Simple Handlebars Translation Helper
4
+ * Simple Twig Translation Helper
5
5
  *
6
6
  * @dependency: https://www.npmjs.com/package/i18next
7
7
  * http://i18next.com/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitro/app",
3
- "version": "9.4.2",
3
+ "version": "10.0.0",
4
4
  "description": "Nitro server",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "author": "The Nitro Team",
11
11
  "engines": {
12
- "node": ">=18.12.0 <21",
13
- "npm": ">=8.19.2 <11"
12
+ "node": ">=20.18.1 <21",
13
+ "npm": ">=10.8.2 <11"
14
14
  },
15
15
  "bin": {
16
16
  "nitro-app-validate-pattern-data": "bin/validate-pattern-data.js",
@@ -35,9 +35,9 @@
35
35
  "ajv": "8.17.1",
36
36
  "body-parser": "2.2.0",
37
37
  "cli-color": "2.0.4",
38
- "compression": "1.8.0",
39
- "cookie-session": "2.1.0",
40
- "config": "3.3.12",
38
+ "compression": "1.8.1",
39
+ "cookie-session": "2.1.1",
40
+ "config": "4.1.0",
41
41
  "dot-object": "2.1.5",
42
42
  "express": "4.21.2",
43
43
  "extend": "3.0.2",
@@ -45,12 +45,12 @@
45
45
  "hbs": "4.2.0",
46
46
  "hbs-utils": "0.0.4",
47
47
  "html-validate": "7.18.1",
48
- "i18next": "24.2.3",
49
- "i18next-http-middleware": "3.7.4",
48
+ "i18next": "25.3.4",
49
+ "i18next-http-middleware": "3.8.0",
50
50
  "i18next-fs-backend": "2.6.0",
51
51
  "i18next-sprintf-postprocessor": "0.2.2",
52
- "jasmine": "5.7.1",
53
- "jasmine-core": "5.7.1",
52
+ "jasmine": "5.9.0",
53
+ "jasmine-core": "5.9.0",
54
54
  "lodash": "4.17.21",
55
55
  "twig": "1.13.3",
56
56
  "webpack": "4.47.0",
@@ -60,7 +60,7 @@
60
60
  "devDependencies": {
61
61
  "@merkle-open/eslint-config": "4.0.0",
62
62
  "eslint": "8.57.1",
63
- "eslint-plugin-import": "2.31.0"
63
+ "eslint-plugin-import": "2.32.0"
64
64
  },
65
65
  "publishConfig": {
66
66
  "access": "public"