express-hbs 3.0.0 → 4.0.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.
Files changed (118) hide show
  1. package/README.md +2 -2
  2. package/lib/hbs.js +7 -1
  3. package/package.json +16 -12
  4. package/.editorconfig +0 -8
  5. package/.github/workflows/publish.yml +0 -73
  6. package/.github/workflows/test.yml +0 -48
  7. package/.jsbeautifyrc +0 -17
  8. package/.nvmrc +0 -1
  9. package/.nycrc.json +0 -16
  10. package/.oxfmtrc.json +0 -19
  11. package/.oxlintrc.json +0 -32
  12. package/AGENTS.md +0 -40
  13. package/SECURITY.md +0 -9
  14. package/example/app-layoutsDir.js +0 -99
  15. package/example/app.js +0 -103
  16. package/example/public/css/style.css +0 -17
  17. package/example/views/fruits/details-layoutsDir.hbs +0 -3
  18. package/example/views/fruits/details.hbs +0 -4
  19. package/example/views/fruits/index-layoutsDir.hbs +0 -20
  20. package/example/views/fruits/index.hbs +0 -20
  21. package/example/views/index.hbs +0 -34
  22. package/example/views/layout/default.hbs +0 -13
  23. package/example/views/layout/fruit-details.hbs +0 -9
  24. package/example/views/layout/fruits.hbs +0 -6
  25. package/example/views/layout/html-struct.hbs +0 -21
  26. package/example/views/layout/veggie-details.hbs +0 -9
  27. package/example/views/layout/veggie.hbs +0 -6
  28. package/example/views/partials/scripts.hbs +0 -5
  29. package/example/views/partials/sub/comment.hbs +0 -1
  30. package/example/views/partials-other/other.hbs +0 -1
  31. package/example/views/replace.hbs +0 -6
  32. package/example/views/tos.txt +0 -3
  33. package/example/views/veggies/details.hbs +0 -1
  34. package/example/views/veggies.hbs +0 -17
  35. package/renovate.json +0 -13
  36. package/test/apps/async/index.js +0 -139
  37. package/test/apps/async/views/failer.hbs +0 -4
  38. package/test/apps/async/views/index.hbs +0 -16
  39. package/test/apps/async/views/layout.hbs +0 -1
  40. package/test/apps/i18n/index.js +0 -57
  41. package/test/apps/i18n/locales/en.json +0 -8
  42. package/test/apps/i18n/locales/fr.json +0 -8
  43. package/test/apps/i18n/views/index.hbs +0 -3
  44. package/test/asyncSpecs.js +0 -69
  45. package/test/cacheSpecs.js +0 -135
  46. package/test/customExtension.js +0 -35
  47. package/test/handlebarsSpecs.js +0 -92
  48. package/test/helperSpecs.js +0 -58
  49. package/test/helpers.js +0 -24
  50. package/test/i18nSpecs.js +0 -36
  51. package/test/issues/144/index.hbs +0 -1
  52. package/test/issues/153/index.hbs +0 -3
  53. package/test/issues/21/views/index.hbs +0 -1
  54. package/test/issues/21/views/layouts/default.hbs +0 -1
  55. package/test/issues/21/views/layouts/sub/child.hbs +0 -1
  56. package/test/issues/21/views/sub/relativeLayout.hbs +0 -1
  57. package/test/issues/21/views/sub/sub.hbs +0 -1
  58. package/test/issues/21/views/useLayoutInDir.hbs +0 -1
  59. package/test/issues/22/layout1.hbs +0 -1
  60. package/test/issues/22/layout2.hbs +0 -1
  61. package/test/issues/22/template.hbs +0 -1
  62. package/test/issues/23/empty.hbs +0 -0
  63. package/test/issues/23/emptyComment.hbs +0 -1
  64. package/test/issues/23/emptyPartial.hbs +0 -1
  65. package/test/issues/23/index.hbs +0 -4
  66. package/test/issues/23/layout.hbs +0 -1
  67. package/test/issues/23/partials/custom/comment-only.hbs +0 -1
  68. package/test/issues/23/partials/custom/empty.hbs +0 -0
  69. package/test/issues/23/partials/hello.hbs +0 -1
  70. package/test/issues/49/error.hbs +0 -1
  71. package/test/issues/49/front/error.hbs +0 -1
  72. package/test/issues/49/index.hbs +0 -2
  73. package/test/issues/49/layouts/default.hbs +0 -1
  74. package/test/issues/49/partial.hbs +0 -1
  75. package/test/issues/49/partials/partial-error.hbs +0 -1
  76. package/test/issues/53/default.hbs +0 -15
  77. package/test/issues/53/index.hbs +0 -7
  78. package/test/issues/53/partials/.gitkeep +0 -0
  79. package/test/issues/59/index.hbs +0 -2
  80. package/test/issues/62/basic.hbs +0 -2
  81. package/test/issues/62/block.hbs +0 -11
  82. package/test/issues/73/index.hbs +0 -5
  83. package/test/issues/73/partials/partial.hbs +0 -6
  84. package/test/issues/76/mypartial.hbs +0 -0
  85. package/test/issues/84/index.hbs +0 -1
  86. package/test/issues/84/partials/abc/def/ghi/test.hbs +0 -1
  87. package/test/issues.js +0 -490
  88. package/test/layoutSpecs.js +0 -116
  89. package/test/localTemplateOptions/data-access-template.hbs +0 -1
  90. package/test/localTemplateOptions/template.hbs +0 -1
  91. package/test/localTemplateOptions.js +0 -125
  92. package/test/multiple.js +0 -115
  93. package/test/nonExpress.js +0 -36
  94. package/test/optionsSpecs.js +0 -22
  95. package/test/resolverSpecs.js +0 -54
  96. package/test/views/beautify/expected.hbs +0 -9
  97. package/test/views/beautify/index.hbs +0 -2
  98. package/test/views/customExtension/layout.server.view.html +0 -1
  99. package/test/views/customExtension/partialsDir/partial1.server.view.html +0 -1
  100. package/test/views/customExtension/partialsDir/partial2.server.view.html +0 -1
  101. package/test/views/customExtension/partialsDir/subs/subPartial1.server.view.html +0 -1
  102. package/test/views/customExtension/partialsDir/subs/subPartial2.server.view.html +0 -1
  103. package/test/views/customExtension/template.server.view.html +0 -5
  104. package/test/views/disableLayoutDirective/aside.hbs +0 -1
  105. package/test/views/disableLayoutDirective/index.hbs +0 -2
  106. package/test/views/disableLayoutDirective/layouts/default.hbs +0 -1
  107. package/test/views/helpers/home/async.hbs +0 -6
  108. package/test/views/helpers/home/index.hbs +0 -3
  109. package/test/views/helpers/layouts/default.hbs +0 -1
  110. package/test/views/multiple/views1/collide.hbs +0 -1
  111. package/test/views/multiple/views1/error.hbs +0 -1
  112. package/test/views/multiple/views1/test1.hbs +0 -1
  113. package/test/views/multiple/views2/collide.hbs +0 -1
  114. package/test/views/multiple/views2/error.hbs +0 -1
  115. package/test/views/multiple/views2/test2.hbs +0 -1
  116. package/test/views/viewsDir/layouts/default.hbs +0 -1
  117. package/test/views/viewsDir/sub/directive.hbs +0 -2
  118. package/test/views/viewsDir/sub/lay.hbs +0 -1
@@ -1,92 +0,0 @@
1
- var request = require('supertest');
2
- var assert = require('assert');
3
- var hbs = require('..');
4
-
5
- describe('express-hbs', function () {
6
- describe('defaults', function () {
7
- var app;
8
-
9
- beforeEach(function () {
10
- var example = require('../example/app');
11
- app = example.create(hbs.create());
12
- });
13
-
14
- it('should render using default layout', function (done) {
15
- request(app)
16
- .get('/')
17
- .expect(/DEFAULT LAYOUT/, done);
18
- });
19
-
20
- it('should render layout declared in markup', function (done) {
21
- request(app)
22
- .get('/fruits')
23
- .expect(/DECLARATIVE LAYOUT/, done);
24
- });
25
-
26
- it('should render nested declarative layouts correctly', function (done) {
27
- request(app)
28
- .get('/fruits/apple')
29
- .expect(/DECLARATIVE LAYOUT/)
30
- .expect(/NESTED LAYOUT/, done);
31
- });
32
-
33
- it('should render layout specified as locals', function (done) {
34
- request(app)
35
- .get('/veggies')
36
- .expect(/PROGRAMMATIC LAYOUT/, done);
37
- });
38
-
39
- it('should render nested layouts correctly when first layout is specified as locals', function (done) {
40
- request(app)
41
- .get('/veggies/carrot')
42
- .expect(/PROGRAMMATIC LAYOUT/)
43
- .expect(/NESTED LAYOUT/, done);
44
- });
45
-
46
- it('should render partial', function (done) {
47
- request(app)
48
- .get('/veggies')
49
- .expect(/jquery\.js/)
50
- .expect(/Other partial/, done);
51
- });
52
-
53
- it('should render sub partial', function (done) {
54
- request(app)
55
- .get('/veggies')
56
- .expect(/just a comment/, done);
57
- });
58
-
59
- it('should render block', function (done) {
60
- request(app)
61
- .get('/')
62
- .expect(/color: blue/, done);
63
- });
64
-
65
- it('should render block default content', function (done) {
66
- request(app)
67
- .get('/')
68
- .expect(/Default block content/, done);
69
- });
70
-
71
- it('should render block content instead of default content when contentFor is declared', function (done) {
72
- request(app)
73
- .get('/replace')
74
- .expect(/Non-default block content/, done);
75
- });
76
-
77
- it('should replace {{body}}', function (done) {
78
- request(app)
79
- .get('/')
80
- .expect(/Vegetables/, done);
81
- });
82
- });
83
-
84
- describe('instances', function () {
85
- it('should create isolated instances', function () {
86
- var hbs2 = hbs.create();
87
- var hbs3 = hbs.create();
88
-
89
- assert(hbs !== hbs2 && hbs !== hbs3 && hbs2 !== hbs3);
90
- });
91
- });
92
- });
@@ -1,58 +0,0 @@
1
- var assert = require('assert');
2
- var hbs = require('..');
3
- var H = require('./helpers');
4
-
5
- describe('helpers', function () {
6
- describe('sync', function () {
7
- var dirname = __dirname + '/views/helpers';
8
-
9
- function sync(s, options) {
10
- return new hbs.SafeString('-sync-' + s);
11
- }
12
-
13
- it('should register functions', function (done) {
14
- var hb = hbs.create();
15
- hb.registerHelper('sync', sync);
16
- var render = hb.express3({
17
- viewsDir: dirname,
18
- restrictLayoutsTo: dirname,
19
- });
20
- var locals = H.createLocals('express3', dirname);
21
-
22
- render(dirname + '/home/index.hbs', locals, function (err, html) {
23
- assert.equal('<default>index-sync-index</default>', H.stripWs(html));
24
- done();
25
- });
26
- });
27
- });
28
-
29
- describe('async', function () {
30
- var dirname = __dirname + '/views/helpers';
31
- it('should register functions', function (done) {
32
- var hb = hbs.create();
33
- function async(s, cb) {
34
- setTimeout(
35
- function () {
36
- cb(new hb.SafeString('-async-' + s));
37
- },
38
- Math.floor(Math.random() * 10 + 1),
39
- );
40
- }
41
- hb.registerAsyncHelper('async', async);
42
-
43
- var render = hb.express3({
44
- viewsDir: dirname,
45
- restrictLayoutsTo: dirname,
46
- });
47
- var locals = H.createLocals('express3', dirname);
48
-
49
- render(dirname + '/home/async.hbs', locals, function (err, html) {
50
- assert.equal(
51
- '<default>asynctemplate-async-foo-async-bar-async-bah-async-baz</default>',
52
- H.stripWs(html),
53
- );
54
- done();
55
- });
56
- });
57
- });
58
- });
package/test/helpers.js DELETED
@@ -1,24 +0,0 @@
1
- function stripWs(s) {
2
- return s.replace(/\s+/g, '');
3
- }
4
-
5
- function createLocals(which, viewsDir, locals) {
6
- if (!locals) locals = {};
7
- var opts = {};
8
- if (which === 'express3' || which === 'express4') {
9
- opts.settings = {
10
- views: viewsDir,
11
- };
12
- opts.cache = process.env.NODE_ENV === 'production';
13
- for (var k in locals) {
14
- if (!locals.hasOwnProperty(k)) continue;
15
- opts[k] = locals[k];
16
- }
17
- }
18
- return opts;
19
- }
20
-
21
- module.exports = {
22
- createLocals: createLocals,
23
- stripWs: stripWs,
24
- };
package/test/i18nSpecs.js DELETED
@@ -1,36 +0,0 @@
1
- var request = require('supertest');
2
- var assert = require('assert');
3
- var hbs = require('..');
4
-
5
- describe('i18n', function () {
6
- var app;
7
-
8
- beforeEach(function () {
9
- var apper = require('./apps/i18n');
10
- app = apper.create(hbs.create());
11
- });
12
-
13
- it('should render en', function (done) {
14
- request(app)
15
- .get('/')
16
- .set('Cookie', 'locale=en')
17
- .end(function (req, res) {
18
- var expected =
19
- '<span id="text">text to test</span>\n<br>\n<span class="each">1 cat</span><span class="each">2 cats</span>';
20
- assert.equal(res.text, expected);
21
- done();
22
- });
23
- });
24
-
25
- it('should render fr', function (done) {
26
- request(app)
27
- .get('/')
28
- .set('Cookie', 'locale=fr')
29
- .end(function (req, res) {
30
- var expected =
31
- '<span id="text">Texte à tester</span>\n<br>\n<span class="chaque">1 chat</span><span class="chaque">2 chats</span>';
32
- assert.equal(res.text, expected);
33
- done();
34
- });
35
- });
36
- });
@@ -1 +0,0 @@
1
- <div>{{special_string}}</div>
@@ -1,3 +0,0 @@
1
- {{#contentFor "testBlock"}}1{{/contentFor}}
2
- {{#contentFor "testBlock"}}2{{/contentFor}}
3
- {{{block "testBlock"}}}
@@ -1 +0,0 @@
1
- index
@@ -1 +0,0 @@
1
- <html>{{{body}}}</html>
@@ -1 +0,0 @@
1
- <sub>{{{body}}}</sub>
@@ -1 +0,0 @@
1
- <relative>{{{body}}}</relative>
@@ -1 +0,0 @@
1
- sub
@@ -1 +0,0 @@
1
- useLayoutInDir
@@ -1 +0,0 @@
1
- <layout1>{{{body}}}</layout1>
@@ -1 +0,0 @@
1
- <layout2>{{{body}}}</layout2>
@@ -1 +0,0 @@
1
- template
File without changes
@@ -1 +0,0 @@
1
- foo{{> emptyComment}}
@@ -1 +0,0 @@
1
- foo{{> emptyPartial}}
@@ -1,4 +0,0 @@
1
- {{!< layout.hbs}}
2
- {{> custom/empty}}
3
- {{> custom/comment-only}}
4
- {{> hello}}
@@ -1 +0,0 @@
1
- <html>{{{body}}}</html>
@@ -1 +0,0 @@
1
- {{! comment }}
File without changes
@@ -1 +0,0 @@
1
- Hello
@@ -1 +0,0 @@
1
- {{{http://google.co.uk}}
@@ -1 +0,0 @@
1
- {{{http://google.co.uk}}
@@ -1,2 +0,0 @@
1
- {{!< layouts/default.hbs}}
2
- index
@@ -1 +0,0 @@
1
- <layout>{{{body}}</layout>
@@ -1 +0,0 @@
1
- {{> partial-error}}
@@ -1 +0,0 @@
1
- {{{body}}
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>{{title}}</title>
5
- </head>
6
- <body>
7
- <h1>{{name}}</h1>
8
-
9
- {{{body}}}
10
-
11
- {{{block "meta"}}}
12
-
13
- <h2>Strangely not so weird</h2>
14
- {{weird}}
15
- </body>
@@ -1,7 +0,0 @@
1
- {{!< default}}
2
-
3
- <p>Expected behaviour (sub-template): <strong>{{weird}}</strong></p>
4
-
5
- {{#contentFor 'meta'}}
6
- <p>Unexpected behaviour: <strong>{{weird}}</strong></p>
7
- {{/contentFor}}
File without changes
@@ -1,2 +0,0 @@
1
- {{async "foo"}}
2
- {{{async "foo"}}}
@@ -1,2 +0,0 @@
1
- {{async "foo"}}
2
- {{async "foo" type="em"}}
@@ -1,11 +0,0 @@
1
- {{#async "World" inverse="true"}}
2
- <p>Hello {{output}}</p>
3
- {{else}}
4
- <p>Goodbye {{output}}</p>
5
- {{/async}}
6
-
7
- {{#async "Handlebars" inverse="false"}}
8
- <p>Hello {{output}}</p>
9
- {{else}}
10
- <p>Goodbye {{output}}</p>
11
- {{/async}}
@@ -1,5 +0,0 @@
1
- <div>
2
- <div>
3
- {{> partial}}
4
- </div>
5
- </div>
@@ -1,6 +0,0 @@
1
- <pre>
2
- <code>
3
- Hello World, I don't want any indentation
4
- second line
5
- </code>
6
- </pre>
File without changes
@@ -1 +0,0 @@
1
- <div>{{> abc/def/ghi/test}}</div>
@@ -1 +0,0 @@
1
- Testing 3 levels down