Skip to content

Commit 9413ea9

Browse files
committed
Format *.md files with prettier
The `npm run format` command now matches the husky `lint-staged`-commands. Also upgraded to prettier v3.
1 parent f202c50 commit 9413ea9

File tree

12 files changed

+117
-117
lines changed

12 files changed

+117
-117
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Upgrade to Prettier 2.7
2-
3d228334530860a6e3f99dc10777c84bf22292c1
2+
3d228334530860a6e3f99dc10777c84bf22292c1
3+
# Format markdown files with Prettier
4+
dfe2eaaf20f0b679d94e5a799757c4394d80f1cc

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ Before filing issues, please check the following points first:
55
- [ ] Read the FAQ at https://github.com/handlebars-lang/handlebars.js/blob/master/FAQ.md
66
- [ ] Use the jsfiddle-template at https://jsfiddle.net/4nbwjaqz/4/ to reproduce problems or bugs
77

8-
This will probably help you to get a solution faster.
8+
This will probably help you to get a solution faster.
99
For bugs, it would be great to have a PR with a failing test-case.
10-
11-

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Generally we like to see pull requests that
99
- [ ] Have tests
1010
- [ ] Have the [typings](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) (lib/handlebars.d.ts) updated on every API change. If you need help, updating those, please mention that in the PR description.
1111
- [ ] Don't significantly decrease the current code coverage (see coverage/lcov-report/index.html)
12-
- [ ] Currently, the `4.x`-branch contains the latest version. Please target that branch in the PR.
12+
- [ ] Currently, the `4.x`-branch contains the latest version. Please target that branch in the PR.

FAQ.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,53 @@
22

33
## How can I file a bug report:
44

5-
See our guidelines on [reporting issues](https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues).
5+
See our guidelines on [reporting issues](https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues).
66

77
## Why isn't my Mustache template working?
88

9-
Handlebars deviates from Mustache slightly on a few behaviors. These variations are documented in our [readme](https://github.com/handlebars-lang/handlebars.js#differences-between-handlebarsjs-and-mustache).
9+
Handlebars deviates from Mustache slightly on a few behaviors. These variations are documented in our [readme](https://github.com/handlebars-lang/handlebars.js#differences-between-handlebarsjs-and-mustache).
1010

1111
## Why is it slower when compiling?
1212

13-
The Handlebars compiler must parse the template and construct a JavaScript program which can then be run. Under some environments such as older mobile devices this can have a performance impact which can be avoided by precompiling. Generally it's recommended that precompilation and the runtime library be used on all clients.
13+
The Handlebars compiler must parse the template and construct a JavaScript program which can then be run. Under some environments such as older mobile devices this can have a performance impact which can be avoided by precompiling. Generally it's recommended that precompilation and the runtime library be used on all clients.
1414

1515
## Why doesn't this work with Content Security Policy restrictions?
1616

17-
When not using the precompiler, Handlebars generates a dynamic function for each template which can cause issues with pages that have enabled Content Policy. It's recommended that templates are precompiled or the `unsafe-eval` policy is enabled for sites that must generate dynamic templates at runtime.
17+
When not using the precompiler, Handlebars generates a dynamic function for each template which can cause issues with pages that have enabled Content Policy. It's recommended that templates are precompiled or the `unsafe-eval` policy is enabled for sites that must generate dynamic templates at runtime.
1818

1919
## How can I include script tags in my template?
2020

21-
If loading the template via an inlined `<script type="text/x-handlebars">` tag then you may need to break up the script tag with an empty comment to avoid browser parser errors:
21+
If loading the template via an inlined `<script type="text/x-handlebars">` tag then you may need to break up the script tag with an empty comment to avoid browser parser errors:
2222

23-
```html
24-
<script type="text/x-handlebars">
25-
foo
26-
<scr{{!}}ipt src="bar"></scr{{!}}ipt>
27-
</script>
28-
```
23+
```html
24+
<script type="text/x-handlebars">
25+
foo
26+
<scr{{!}}ipt src="bar"></scr{{!}}ipt>
27+
</script>
28+
```
2929

30-
It's generally recommended that templates are served through external, precompiled, files, which do not suffer from this issue.
30+
It's generally recommended that templates are served through external, precompiled, files, which do not suffer from this issue.
3131

3232
## Why are my precompiled scripts throwing exceptions?
3333

34-
When using the precompiler, it's important that a supporting version of the Handlebars runtime be loaded on the target page. In version 1.x there were rudimentary checks to compare the version but these did not always work. This is fixed under 2.x but the version checking does not work between these two versions. If you see unexpected errors such as `undefined is not a function` or similar, please verify that the same version is being used for both the precompiler and the client. This can be checked via:
34+
When using the precompiler, it's important that a supporting version of the Handlebars runtime be loaded on the target page. In version 1.x there were rudimentary checks to compare the version but these did not always work. This is fixed under 2.x but the version checking does not work between these two versions. If you see unexpected errors such as `undefined is not a function` or similar, please verify that the same version is being used for both the precompiler and the client. This can be checked via:
3535

36-
```sh
37-
handlebars --version
38-
```
36+
```sh
37+
handlebars --version
38+
```
3939

40-
If using the integrated precompiler and
40+
If using the integrated precompiler and
4141

42-
```javascript
43-
console.log(Handlebars.VERSION);
44-
```
42+
```javascript
43+
console.log(Handlebars.VERSION);
44+
```
4545

46-
On the client side.
46+
On the client side.
4747

48-
We include the built client libraries in the npm package for those who want to be certain that they are using the same client libraries as the compiler.
48+
We include the built client libraries in the npm package for those who want to be certain that they are using the same client libraries as the compiler.
4949

50-
Should these match, please file an issue with us, per our [issue filing guidelines](https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues).
50+
Should these match, please file an issue with us, per our [issue filing guidelines](https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues).
5151

5252
## How do I load the runtime library when using AMD?
5353

54-
The `handlebars.runtime.js` file includes a UMD build, which exposes the library as both the module root and the `default` field for compatibility.
54+
The `handlebars.runtime.js` file includes a UMD build, which exposes the library as both the module root and the `default` field for compatibility.

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ We recommend always using the latest versions of Handlebars and its official com
55
## Supported Versions
66

77
| Version | Supported |
8-
|---------| ------------------ |
8+
| ------- | ------------------ |
99
| 5.0.x | :white_check_mark: |
1010
| 4.7.x | :white_check_mark: |
1111
| < 4.7 | :x: |

components/component.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
"repo": "components/handlebars.js",
44
"version": "1.0.0",
55
"main": "handlebars.js",
6-
"scripts": [
7-
"handlebars.js"
8-
]
6+
"scripts": ["handlebars.js"]
97
}

components/composer.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
{
2-
"name": "components/handlebars.js",
3-
"description": "Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.",
4-
"homepage": "http://handlebarsjs.com",
5-
"license": "MIT",
6-
"type": "component",
7-
"keywords": [
8-
"handlebars",
9-
"mustache",
10-
"html"
11-
],
12-
"authors": [
13-
{
14-
"name": "Chris Wanstrath",
15-
"homepage": "http://chriswanstrath.com"
16-
}
17-
],
18-
"require": {
19-
"robloach/component-installer": "*"
20-
},
21-
"extra": {
22-
"component": {
23-
"name": "handlebars",
24-
"scripts": [
25-
"handlebars.js"
26-
],
27-
"files": [
28-
"handlebars.runtime.js"
29-
],
30-
"shim": {
31-
"exports": "Handlebars"
32-
}
33-
}
2+
"name": "components/handlebars.js",
3+
"description": "Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.",
4+
"homepage": "http://handlebarsjs.com",
5+
"license": "MIT",
6+
"type": "component",
7+
"keywords": [
8+
"handlebars",
9+
"mustache",
10+
"html"
11+
],
12+
"authors": [
13+
{
14+
"name": "Chris Wanstrath",
15+
"homepage": "http://chriswanstrath.com"
3416
}
17+
],
18+
"require": {
19+
"robloach/component-installer": "*"
20+
},
21+
"extra": {
22+
"component": {
23+
"name": "handlebars",
24+
"scripts": [
25+
"handlebars.js"
26+
],
27+
"files": [
28+
"handlebars.runtime.js"
29+
],
30+
"shim": {
31+
"exports": "Handlebars"
32+
}
33+
}
34+
}
3535
}

docs/compiler-api.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ let ast = Handlebars.parseWithoutProcessing(myTemplate);
3434

3535
`Handlebars.parse` will parse the template with `parseWithoutProcessing` (see above) then it will update the AST to strip extraneous whitespace. The whitespace stripping functionality handles two distinct situations:
3636

37-
* Removes whitespace around dynamic statements that are on a line by themselves (aka "stand alone")
38-
* Applies "whitespace control" characters (i.e. `~`) by truncating the `ContentStatement` `value` property appropriately (e.g. `\n\n{{~foo}}` would have a `ContentStatement` with a `value` of `''`)
37+
- Removes whitespace around dynamic statements that are on a line by themselves (aka "stand alone")
38+
- Applies "whitespace control" characters (i.e. `~`) by truncating the `ContentStatement` `value` property appropriately (e.g. `\n\n{{~foo}}` would have a `ContentStatement` with a `value` of `''`)
3939

4040
`Handlebars.parse` is used internally by `Handlebars.precompile` and `Handlebars.compile`.
4141

@@ -71,7 +71,7 @@ interface Position {
7171
interface Program <: Node {
7272
type: "Program";
7373
body: [ Statement ];
74-
74+
7575
blockParams: [ string ];
7676
}
7777
```
@@ -132,7 +132,6 @@ interface PartialBlockStatement <: Statement {
132132

133133
`name` will be a `SubExpression` when tied to a dynamic partial, i.e. `{{> (foo) }}`, otherwise this is a path or literal whose `original` value is used to lookup the desired partial.
134134

135-
136135
```java
137136
interface ContentStatement <: Statement {
138137
type: "ContentStatement";
@@ -148,7 +147,6 @@ interface CommentStatement <: Statement {
148147
}
149148
```
150149

151-
152150
```java
153151
interface Decorator <: Statement {
154152
type: "Decorator";
@@ -209,7 +207,6 @@ interface PathExpression <: Expression {
209207
- `parts` is an array of the names in the path. `foo.bar` would be `['foo', 'bar']`. Scope references, `.`, `..`, and `this` should be omitted from this array.
210208
- `original` is the path as entered by the user. Separator and scope references are left untouched.
211209

212-
213210
##### Literals
214211

215212
```java
@@ -242,7 +239,6 @@ interface NullLiteral <: Literal {
242239
}
243240
```
244241

245-
246242
### Miscellaneous
247243

248244
```java
@@ -279,8 +275,8 @@ function ImportScanner() {
279275
}
280276
ImportScanner.prototype = new Visitor();
281277

282-
ImportScanner.prototype.PartialStatement = function(partial) {
283-
this.partials.push({request: partial.name.original});
278+
ImportScanner.prototype.PartialStatement = function (partial) {
279+
this.partials.push({ request: partial.name.original });
284280

285281
Visitor.prototype.PartialStatement.call(this, partial);
286282
};
@@ -309,58 +305,63 @@ The `Handlebars.JavaScriptCompiler` object has a number of methods that may be c
309305
Note that this does not impact dynamic partials, which implementors need to be aware of. Overriding `VM.resolvePartial` may be required to support dynamic cases.
310306

311307
- `depthedLookup(name)`
312-
Used to generate code that resolves parameters within any context in the stack. Is only used in `compat` mode.
308+
Used to generate code that resolves parameters within any context in the stack. Is only used in `compat` mode.
313309

314310
- `compilerInfo()`
315311
Allows for custom compiler flags used in the runtime version checking logic.
316312

317313
- `appendToBuffer(source, location, explicit)`
318-
Allows for code buffer emitting code. Defaults behavior is string concatenation.
314+
Allows for code buffer emitting code. Defaults behavior is string concatenation.
319315

320-
- `source` is the source code whose result is to be appending
321-
- `location` is the location of the source in the source map.
322-
- `explicit` is a flag signaling that the emit operation must occur, vs. the lazy evaled options otherwise.
316+
- `source` is the source code whose result is to be appending
317+
- `location` is the location of the source in the source map.
318+
- `explicit` is a flag signaling that the emit operation must occur, vs. the lazy evaled options otherwise.
323319

324320
- `initializeBuffer()`
325-
Allows for buffers other than the default string buffer to be used. Generally needs to be paired with a custom `appendToBuffer` implementation.
321+
Allows for buffers other than the default string buffer to be used. Generally needs to be paired with a custom `appendToBuffer` implementation.
326322

327323
### Example for the compiler api.
328324

329325
This example changes all lookups of properties are performed by a helper (`lookupLowerCase`) which looks for `test` if `{{Test}}` occurs in the template. This is just to illustrate how compiler behavior can be change.
330326

331327
There is also [a jsfiddle with this code](https://jsfiddle.net/9D88g/162/) if you want to play around with it.
332328

333-
334329
```javascript
335330
function MyCompiler() {
336331
Handlebars.JavaScriptCompiler.apply(this, arguments);
337332
}
338333
MyCompiler.prototype = new Handlebars.JavaScriptCompiler();
339334

340335
// Use this compile to compile BlockStatment-Blocks
341-
MyCompiler.prototype.compiler = MyCompiler
336+
MyCompiler.prototype.compiler = MyCompiler;
342337

343-
MyCompiler.prototype.nameLookup = function(parent, name, type) {
338+
MyCompiler.prototype.nameLookup = function (parent, name, type) {
344339
if (type === 'context') {
345-
return this.source.functionCall('helpers.lookupLowerCase', '', [parent, JSON.stringify(name)])
340+
return this.source.functionCall('helpers.lookupLowerCase', '', [
341+
parent,
342+
JSON.stringify(name),
343+
]);
346344
} else {
347-
return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(this, parent, name, type);
345+
return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(
346+
this,
347+
parent,
348+
name,
349+
type
350+
);
348351
}
349-
}
352+
};
350353

351354
var env = Handlebars.create();
352-
env.registerHelper('lookupLowerCase', function(parent, name) {
353-
return parent[name.toLowerCase()]
354-
})
355+
env.registerHelper('lookupLowerCase', function (parent, name) {
356+
return parent[name.toLowerCase()];
357+
});
355358

356359
env.JavaScriptCompiler = MyCompiler;
357360

358361
var template = env.compile('{{#each Test}} ({{Value}}) {{/each}}');
359-
console.log(template({
360-
test: [
361-
{value: 'a'},
362-
{value: 'b'},
363-
{value: 'c'}
364-
]
365-
}));
362+
console.log(
363+
template({
364+
test: [{ value: 'a' }, { value: 'b' }, { value: 'c' }],
365+
})
366+
);
366367
```

0 commit comments

Comments
 (0)