express-hbs 2.5.0 → 4.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.
- package/LICENSE +1 -1
- package/README.md +50 -22
- package/lib/hbs.js +89 -91
- package/lib/resolver.js +10 -9
- package/package.json +32 -21
- package/.editorconfig +0 -8
- package/.eslintrc +0 -42
- package/.github/workflows/test.yml +0 -24
- package/.jsbeautifyrc +0 -17
- package/SECURITY.md +0 -9
- package/example/app-layoutsDir.js +0 -106
- package/example/app.js +0 -110
- package/example/public/css/style.css +0 -17
- package/example/views/fruits/details-layoutsDir.hbs +0 -3
- package/example/views/fruits/details.hbs +0 -4
- package/example/views/fruits/index-layoutsDir.hbs +0 -20
- package/example/views/fruits/index.hbs +0 -20
- package/example/views/index.hbs +0 -34
- package/example/views/layout/default.hbs +0 -13
- package/example/views/layout/fruit-details.hbs +0 -9
- package/example/views/layout/fruits.hbs +0 -6
- package/example/views/layout/html-struct.hbs +0 -21
- package/example/views/layout/veggie-details.hbs +0 -9
- package/example/views/layout/veggie.hbs +0 -6
- package/example/views/partials/scripts.hbs +0 -5
- package/example/views/partials/sub/comment.hbs +0 -1
- package/example/views/partials-other/other.hbs +0 -1
- package/example/views/replace.hbs +0 -6
- package/example/views/tos.txt +0 -3
- package/example/views/veggies/details.hbs +0 -1
- package/example/views/veggies.hbs +0 -17
- package/renovate.json +0 -6
- package/test/apps/async/index.js +0 -127
- package/test/apps/async/views/failer.hbs +0 -4
- package/test/apps/async/views/index.hbs +0 -16
- package/test/apps/async/views/layout.hbs +0 -1
- package/test/apps/i18n/index.js +0 -55
- package/test/apps/i18n/locales/en.json +0 -8
- package/test/apps/i18n/locales/fr.json +0 -8
- package/test/apps/i18n/views/index.hbs +0 -3
- package/test/asyncSpecs.js +0 -69
- package/test/cacheSpecs.js +0 -138
- package/test/customExtension.js +0 -36
- package/test/handlebarsSpecs.js +0 -95
- package/test/helperSpecs.js +0 -56
- package/test/helpers.js +0 -24
- package/test/i18nSpecs.js +0 -34
- package/test/issues/144/index.hbs +0 -1
- package/test/issues/153/index.hbs +0 -3
- package/test/issues/21/views/index.hbs +0 -1
- package/test/issues/21/views/layouts/default.hbs +0 -1
- package/test/issues/21/views/layouts/sub/child.hbs +0 -1
- package/test/issues/21/views/sub/relativeLayout.hbs +0 -1
- package/test/issues/21/views/sub/sub.hbs +0 -1
- package/test/issues/21/views/useLayoutInDir.hbs +0 -1
- package/test/issues/22/layout1.hbs +0 -1
- package/test/issues/22/layout2.hbs +0 -1
- package/test/issues/22/template.hbs +0 -1
- package/test/issues/23/empty.hbs +0 -0
- package/test/issues/23/emptyComment.hbs +0 -1
- package/test/issues/23/emptyPartial.hbs +0 -1
- package/test/issues/23/index.hbs +0 -4
- package/test/issues/23/layout.hbs +0 -1
- package/test/issues/23/partials/custom/comment-only.hbs +0 -1
- package/test/issues/23/partials/custom/empty.hbs +0 -0
- package/test/issues/23/partials/hello.hbs +0 -1
- package/test/issues/49/error.hbs +0 -1
- package/test/issues/49/front/error.hbs +0 -1
- package/test/issues/49/index.hbs +0 -2
- package/test/issues/49/layouts/default.hbs +0 -1
- package/test/issues/49/partial.hbs +0 -1
- package/test/issues/49/partials/partial-error.hbs +0 -1
- package/test/issues/53/default.hbs +0 -15
- package/test/issues/53/index.hbs +0 -7
- package/test/issues/53/partials/.gitkeep +0 -0
- package/test/issues/59/index.hbs +0 -2
- package/test/issues/62/basic.hbs +0 -2
- package/test/issues/62/block.hbs +0 -11
- package/test/issues/73/index.hbs +0 -5
- package/test/issues/73/partials/partial.hbs +0 -6
- package/test/issues/76/mypartial.hbs +0 -0
- package/test/issues/84/index.hbs +0 -1
- package/test/issues/84/partials/abc/def/ghi/test.hbs +0 -1
- package/test/issues.js +0 -476
- package/test/layoutSpecs.js +0 -118
- package/test/localTemplateOptions/data-access-template.hbs +0 -1
- package/test/localTemplateOptions/template.hbs +0 -1
- package/test/localTemplateOptions.js +0 -127
- package/test/multiple.js +0 -119
- package/test/nonExpress.js +0 -37
- package/test/optionsSpecs.js +0 -24
- package/test/views/beautify/expected.hbs +0 -9
- package/test/views/beautify/index.hbs +0 -2
- package/test/views/customExtension/layout.server.view.html +0 -1
- package/test/views/customExtension/partialsDir/partial1.server.view.html +0 -1
- package/test/views/customExtension/partialsDir/partial2.server.view.html +0 -1
- package/test/views/customExtension/partialsDir/subs/subPartial1.server.view.html +0 -1
- package/test/views/customExtension/partialsDir/subs/subPartial2.server.view.html +0 -1
- package/test/views/customExtension/template.server.view.html +0 -5
- package/test/views/disableLayoutDirective/aside.hbs +0 -1
- package/test/views/disableLayoutDirective/index.hbs +0 -2
- package/test/views/disableLayoutDirective/layouts/default.hbs +0 -1
- package/test/views/helpers/home/async.hbs +0 -6
- package/test/views/helpers/home/index.hbs +0 -3
- package/test/views/helpers/layouts/default.hbs +0 -1
- package/test/views/multiple/views1/collide.hbs +0 -1
- package/test/views/multiple/views1/error.hbs +0 -1
- package/test/views/multiple/views1/test1.hbs +0 -1
- package/test/views/multiple/views2/collide.hbs +0 -1
- package/test/views/multiple/views2/error.hbs +0 -1
- package/test/views/multiple/views2/test2.hbs +0 -1
- package/test/views/viewsDir/layouts/default.hbs +0 -1
- package/test/views/viewsDir/sub/directive.hbs +0 -2
- package/test/views/viewsDir/sub/lay.hbs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-hbs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Express handlebars template engine complete with multiple layouts, partials and blocks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"express4",
|
|
@@ -10,17 +10,16 @@
|
|
|
10
10
|
"partials"
|
|
11
11
|
],
|
|
12
12
|
"main": "index.js",
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"lib"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22"
|
|
19
|
+
},
|
|
13
20
|
"directories": {
|
|
14
21
|
"example": "example"
|
|
15
22
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"lint": "eslint --ext .js --cache lib/**",
|
|
18
|
-
"test": "mocha",
|
|
19
|
-
"posttest": "yarn lint",
|
|
20
|
-
"coverage": "nyc yarn test",
|
|
21
|
-
"preship": "yarn test",
|
|
22
|
-
"ship": "STATUS=$(git status --porcelain); echo $STATUS; if [ -z \"$STATUS\" ]; then yarn publish && git push --follow-tags; fi"
|
|
23
|
-
},
|
|
24
23
|
"repository": {
|
|
25
24
|
"type": "git",
|
|
26
25
|
"url": "https://github.com/TryGhost/express-hbs"
|
|
@@ -29,21 +28,33 @@
|
|
|
29
28
|
"author": "Mario Gutierrez <mario@barc.com>",
|
|
30
29
|
"license": "MIT",
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"express": "
|
|
35
|
-
"i18n": "0.15.
|
|
36
|
-
"mocha": "
|
|
37
|
-
"nyc": "
|
|
38
|
-
"
|
|
39
|
-
"
|
|
31
|
+
"@tryghost/pro-ship": "2.0.1",
|
|
32
|
+
"cookie-parser": "1.4.7",
|
|
33
|
+
"express": "5.3.0",
|
|
34
|
+
"i18n": "0.15.4",
|
|
35
|
+
"mocha": "12.0.3",
|
|
36
|
+
"nyc": "18.0.0",
|
|
37
|
+
"oxfmt": "0.76.0",
|
|
38
|
+
"oxlint": "1.91.0",
|
|
39
|
+
"rewire": "9.0.1",
|
|
40
|
+
"supertest": "7.3.2"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"handlebars": "^4.7.
|
|
43
|
-
"lodash": "^4.
|
|
43
|
+
"handlebars": "^4.7.10",
|
|
44
|
+
"lodash": "^4.18.1",
|
|
44
45
|
"readdirp": "^3.6.0"
|
|
45
46
|
},
|
|
46
47
|
"optionalDependencies": {
|
|
47
|
-
"js-beautify": "^
|
|
48
|
+
"js-beautify": "^2.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"lint": "oxlint --quiet && oxfmt --check .",
|
|
52
|
+
"lint:fix": "oxlint --fix && oxfmt .",
|
|
53
|
+
"format": "oxfmt .",
|
|
54
|
+
"test": "mocha",
|
|
55
|
+
"posttest": "pnpm lint",
|
|
56
|
+
"coverage": "nyc --check-coverage mocha",
|
|
57
|
+
"preship": "pnpm test",
|
|
58
|
+
"ship": "pro-ship"
|
|
48
59
|
}
|
|
49
|
-
}
|
|
60
|
+
}
|
package/.editorconfig
DELETED
package/.eslintrc
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"node": true
|
|
4
|
-
},
|
|
5
|
-
|
|
6
|
-
"globals": {
|
|
7
|
-
"describe": true,
|
|
8
|
-
"beforeEach": true,
|
|
9
|
-
"it": true
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
"rules": {
|
|
13
|
-
"brace-style": [1, "1tbs"],
|
|
14
|
-
"curly": [0, "multi"],
|
|
15
|
-
"eqeqeq": [1, "smart"],
|
|
16
|
-
"max-depth": [1, 4],
|
|
17
|
-
"max-params": [1, 5],
|
|
18
|
-
"new-cap": 2,
|
|
19
|
-
"new-parens": 0,
|
|
20
|
-
"no-constant-condition": 0,
|
|
21
|
-
"no-div-regex": 1,
|
|
22
|
-
"no-else-return": 1,
|
|
23
|
-
"no-extra-parens": 1,
|
|
24
|
-
"no-floating-decimal": 2,
|
|
25
|
-
"no-inner-declarations": 2,
|
|
26
|
-
"no-lonely-if": 1,
|
|
27
|
-
"no-multi-str": 0,
|
|
28
|
-
"no-nested-ternary": 2,
|
|
29
|
-
"no-new-object": 0,
|
|
30
|
-
"no-new-func": 0,
|
|
31
|
-
"no-shadow": 0,
|
|
32
|
-
"no-underscore-dangle": 0,
|
|
33
|
-
"no-unused-vars": 2,
|
|
34
|
-
"quotes": [2, "single", "avoid-escape"],
|
|
35
|
-
"radix": 2,
|
|
36
|
-
"keyword-spacing": "error",
|
|
37
|
-
"object-curly-spacing": ["error", "never"],
|
|
38
|
-
"array-bracket-spacing": ["error", "never"],
|
|
39
|
-
"strict": 2,
|
|
40
|
-
"wrap-iife": 2
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
- 'renovate/*'
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
node: [ 14, 16, 18 ]
|
|
16
|
-
name: Node ${{ matrix.node }}
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
|
19
|
-
- uses: actions/setup-node@v3
|
|
20
|
-
with:
|
|
21
|
-
node-version: ${{ matrix.node }}
|
|
22
|
-
- run: yarn
|
|
23
|
-
- run: yarn lint
|
|
24
|
-
- run: yarn test
|
package/.jsbeautifyrc
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"indent_size": 2,
|
|
3
|
-
"indent_char": " ",
|
|
4
|
-
"indent_level": 0,
|
|
5
|
-
"indent_with_tabs": false,
|
|
6
|
-
"preserve_newlines": true,
|
|
7
|
-
"max_preserve_newlines": 10,
|
|
8
|
-
"jslint_happy": false,
|
|
9
|
-
"brace_style": "collapse",
|
|
10
|
-
"keep_array_indentation": false,
|
|
11
|
-
"keep_function_indentation": false,
|
|
12
|
-
"space_before_conditional": true,
|
|
13
|
-
"break_chained_methods": false,
|
|
14
|
-
"eval_code": false,
|
|
15
|
-
"unescape_strings": false,
|
|
16
|
-
"wrap_line_length": 0
|
|
17
|
-
}
|
package/SECURITY.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Reporting Security Vulnerabilities
|
|
2
|
-
|
|
3
|
-
Potential security vulnerabilities can be reported directly us at `security@ghost.org`. The Ghost Security Team communicates privately and works in a secured, isolated repository for tracking, testing, and resolving security-related issues.
|
|
4
|
-
|
|
5
|
-
The full, up-to-date details of our security policy and procedure can always be found in our documentation:
|
|
6
|
-
|
|
7
|
-
https://ghost.org/docs/security/
|
|
8
|
-
|
|
9
|
-
Please refer to this before emailing us. Thanks for helping make Ghost safe for everyone 🙏.
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// npm install express express-hbs
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var express = require('express');
|
|
6
|
-
var app = express();
|
|
7
|
-
var hbs = require('..'); // should be `require('express-hbs')` outside of this example
|
|
8
|
-
var fs = require('fs');
|
|
9
|
-
var fp = require('path');
|
|
10
|
-
|
|
11
|
-
function relative(path) {
|
|
12
|
-
return fp.join(__dirname, path);
|
|
13
|
-
}
|
|
14
|
-
var viewsDir = relative('views');
|
|
15
|
-
|
|
16
|
-
app.use(express.static(relative('public')));
|
|
17
|
-
|
|
18
|
-
// Hook in express-hbs and tell it where known directories reside
|
|
19
|
-
app.engine('hbs', hbs.express4({
|
|
20
|
-
partialsDir: [relative('views/partials'), relative('views/partials-other')],
|
|
21
|
-
layoutsDir: relative('views/layout'),
|
|
22
|
-
defaultLayout: relative('views/layout/default.hbs'),
|
|
23
|
-
restrictLayoutsTo: relative('views/layout')
|
|
24
|
-
}));
|
|
25
|
-
app.set('view engine', 'hbs');
|
|
26
|
-
app.set('views', relative('views'));
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Register sync helper
|
|
30
|
-
hbs.registerHelper('link', function(text, options) {
|
|
31
|
-
var attrs = [];
|
|
32
|
-
for (var prop in options.hash) {
|
|
33
|
-
attrs.push(prop + '="' + options.hash[prop] + '"');
|
|
34
|
-
}
|
|
35
|
-
return new hbs.SafeString('<a ' + attrs.join(' ') + '>' + text + '</a>');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Register Async helpers
|
|
39
|
-
hbs.registerAsyncHelper('readFile', function(filename, cb) {
|
|
40
|
-
fs.readFile(fp.join(viewsDir, filename), 'utf8', function(err, content) {
|
|
41
|
-
if (err) console.error(err);
|
|
42
|
-
cb(new hbs.SafeString(content));
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var fruits = [
|
|
47
|
-
{name: 'apple'},
|
|
48
|
-
{name: 'orange'},
|
|
49
|
-
{name: 'pear'}
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var veggies = [
|
|
54
|
-
{name: 'asparagus'},
|
|
55
|
-
{name: 'carrot'},
|
|
56
|
-
{name: 'spinach'}
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
app.get('/', function(req, res) {
|
|
60
|
-
res.render('index', {
|
|
61
|
-
title: 'express-hbs example'
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
app.get('/fruits', function(req, res) {
|
|
66
|
-
res.render('fruits/index-layoutsDir', {
|
|
67
|
-
title: 'My favorite fruits',
|
|
68
|
-
fruits: fruits
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
app.get('/fruits/:name', function(req, res) {
|
|
73
|
-
res.render('fruits/details-layoutsDir', {
|
|
74
|
-
fruit: req.params.name
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
app.get('/veggies', function(req, res) {
|
|
79
|
-
res.render('veggies', {
|
|
80
|
-
title: 'My favorite veggies',
|
|
81
|
-
veggies: veggies,
|
|
82
|
-
layout: 'veggie'
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
app.get('/veggies/explicit-dir', function(req, res) {
|
|
87
|
-
res.render('veggies', {
|
|
88
|
-
title: 'My favorite veggies',
|
|
89
|
-
veggies: veggies,
|
|
90
|
-
layout: relative('views/layout/veggie')
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
app.get('/veggies/:name', function(req, res) {
|
|
95
|
-
res.render('veggies/details', {
|
|
96
|
-
veggie: req.params.name,
|
|
97
|
-
layout: 'veggie-details'
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
if (require.main === module) {
|
|
102
|
-
app.listen(3000);
|
|
103
|
-
console.log('Express server listening on port 3000');
|
|
104
|
-
} else {
|
|
105
|
-
module.exports = app;
|
|
106
|
-
}
|
package/example/app.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// npm install express express-hbs
|
|
3
|
-
|
|
4
|
-
function create(hbs, env) {
|
|
5
|
-
if (env) process.env.NODE_ENV = env;
|
|
6
|
-
|
|
7
|
-
var express = require('express');
|
|
8
|
-
var app = express();
|
|
9
|
-
var fs = require('fs');
|
|
10
|
-
var fp = require('path');
|
|
11
|
-
|
|
12
|
-
function relative(path) {
|
|
13
|
-
return fp.join(__dirname, path);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var viewsDir = relative('views');
|
|
17
|
-
|
|
18
|
-
app.use(express.static(relative('public')));
|
|
19
|
-
|
|
20
|
-
// Hook in express-hbs and tell it where known directories reside
|
|
21
|
-
app.engine('hbs', hbs.express4({
|
|
22
|
-
partialsDir: [relative('views/partials'), relative('views/partials-other')],
|
|
23
|
-
defaultLayout: relative('views/layout/default.hbs'),
|
|
24
|
-
restrictLayoutsTo: viewsDir
|
|
25
|
-
}));
|
|
26
|
-
app.set('view engine', 'hbs');
|
|
27
|
-
app.set('views', viewsDir);
|
|
28
|
-
|
|
29
|
-
// Register sync helper
|
|
30
|
-
hbs.registerHelper('link', function(text, options) {
|
|
31
|
-
var attrs = [];
|
|
32
|
-
for (var prop in options.hash) {
|
|
33
|
-
attrs.push(prop + '="' + options.hash[prop] + '"');
|
|
34
|
-
}
|
|
35
|
-
return new hbs.SafeString(
|
|
36
|
-
'<a ' + attrs.join(' ') + '>' + text + '</a>'
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Register Async helpers
|
|
41
|
-
hbs.registerAsyncHelper('readFile', function(filename, cb) {
|
|
42
|
-
fs.readFile(fp.join(viewsDir, filename), 'utf8', function(err, content) {
|
|
43
|
-
if (err) console.error(err);
|
|
44
|
-
cb(new hbs.SafeString(content));
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
var fruits = [
|
|
49
|
-
{name: 'apple'},
|
|
50
|
-
{name: 'orange'},
|
|
51
|
-
{name: 'pear'}
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
var veggies = [
|
|
55
|
-
{name: 'asparagus'},
|
|
56
|
-
{name: 'carrot'},
|
|
57
|
-
{name: 'spinach'}
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
app.get('/', function(req, res) {
|
|
61
|
-
res.render('index', {
|
|
62
|
-
title: 'express-hbs example'
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
app.get('/replace', function(req, res) {
|
|
67
|
-
res.render('replace', {
|
|
68
|
-
title: 'express-hbs example'
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
app.get('/fruits', function(req, res) {
|
|
73
|
-
res.render('fruits/index', {
|
|
74
|
-
title: 'My favorite fruits',
|
|
75
|
-
fruits: fruits
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
app.get('/fruits/:name', function(req, res) {
|
|
80
|
-
res.render('fruits/details', {
|
|
81
|
-
fruit: req.params.name
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
app.get('/veggies', function(req, res) {
|
|
86
|
-
res.render('veggies', {
|
|
87
|
-
title: 'My favorite veggies',
|
|
88
|
-
veggies: veggies,
|
|
89
|
-
layout: 'layout/veggie'
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
app.get('/veggies/:name', function(req, res) {
|
|
94
|
-
res.render('veggies/details', {
|
|
95
|
-
veggie: req.params.name,
|
|
96
|
-
layout: 'layout/veggie-details'
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return app;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (require.main === module) {
|
|
104
|
-
var hbs = require('..');
|
|
105
|
-
var app = create(hbs);
|
|
106
|
-
app.listen(3000);
|
|
107
|
-
console.log('Express server listening on port 3000');
|
|
108
|
-
} else {
|
|
109
|
-
exports.create = create;
|
|
110
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!-- name of layout -->
|
|
2
|
-
{{!< fruits}}
|
|
3
|
-
|
|
4
|
-
{{#contentFor 'pageStyles'}}
|
|
5
|
-
<style>
|
|
6
|
-
li a {
|
|
7
|
-
color: #800;
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
|
-
{{/contentFor}}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<h1>{{title}}</h1>
|
|
14
|
-
<ul>
|
|
15
|
-
{{#each fruits}}
|
|
16
|
-
<li>
|
|
17
|
-
<a href="/fruits/{{this.name}}">{{this.name}}</a>
|
|
18
|
-
</li>
|
|
19
|
-
{{/each}}
|
|
20
|
-
</ul>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!-- name of layout -->
|
|
2
|
-
{{!< ../layout/fruits}}
|
|
3
|
-
|
|
4
|
-
{{#contentFor 'pageStyles'}}
|
|
5
|
-
<style>
|
|
6
|
-
li a {
|
|
7
|
-
color: #800;
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
|
-
{{/contentFor}}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<h1>{{title}}</h1>
|
|
14
|
-
<ul>
|
|
15
|
-
{{#each fruits}}
|
|
16
|
-
<li>
|
|
17
|
-
<a href="/fruits/{{this.name}}">{{this.name}}</a>
|
|
18
|
-
</li>
|
|
19
|
-
{{/each}}
|
|
20
|
-
</ul>
|
package/example/views/index.hbs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{{#contentFor 'pageStyles'}}
|
|
2
|
-
<style>
|
|
3
|
-
.clicker {
|
|
4
|
-
color: blue;
|
|
5
|
-
};
|
|
6
|
-
</style>
|
|
7
|
-
{{/contentFor}}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{{#contentFor 'pageScripts'}}
|
|
11
|
-
<script>
|
|
12
|
-
$(function() {
|
|
13
|
-
$('.clicker').click(function() {
|
|
14
|
-
$(this).text('Hello express-hbs!');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
</script>
|
|
18
|
-
{{/contentFor}}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<h1>{{title}}</h1>
|
|
22
|
-
<p class='clicker'>Click me!</p>
|
|
23
|
-
<p>
|
|
24
|
-
<a href='/fruits'>Favorite fruits</a>
|
|
25
|
-
</p>
|
|
26
|
-
<p>
|
|
27
|
-
<!-- sync helper -->
|
|
28
|
-
{{{link 'Vegetables' href='/veggies'}}}
|
|
29
|
-
</p>
|
|
30
|
-
|
|
31
|
-
<!-- async helper -->
|
|
32
|
-
<div>
|
|
33
|
-
{{{readFile 'tos.txt'}}}
|
|
34
|
-
</div>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>{{title}}</title>
|
|
5
|
-
<link type="text/css" rel="stylesheet" href="/css/style.css"/>
|
|
6
|
-
{{{block "pageStyles"}}}
|
|
7
|
-
</head>
|
|
8
|
-
|
|
9
|
-
<body>
|
|
10
|
-
|
|
11
|
-
<!-- Placeholder for page content. -->
|
|
12
|
-
{{{body}}}
|
|
13
|
-
|
|
14
|
-
<!-- Partials are common snippets to be used 1 or more pages. -->
|
|
15
|
-
{{> scripts}}
|
|
16
|
-
{{> other}}
|
|
17
|
-
|
|
18
|
-
<!-- A block is placeholder for pieces of content defined in a page. -->
|
|
19
|
-
{{{block 'pageScripts'}}}
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!-- just a comment -->
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!-- Other partial -->
|
package/example/views/tos.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{veggie}}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{{#contentFor 'pageStyles'}}
|
|
2
|
-
<style>
|
|
3
|
-
li a {
|
|
4
|
-
color: #800;
|
|
5
|
-
}
|
|
6
|
-
</style>
|
|
7
|
-
{{/contentFor}}
|
|
8
|
-
|
|
9
|
-
{{> sub/comment}}
|
|
10
|
-
<h1>{{title}}</h1>
|
|
11
|
-
<ul>
|
|
12
|
-
{{#each veggies}}
|
|
13
|
-
<li>
|
|
14
|
-
<a href="/veggies/{{this.name}}">{{this.name}}</a>
|
|
15
|
-
</li>
|
|
16
|
-
{{/each}}
|
|
17
|
-
</ul>
|