Skip to content

Commit b8ff144

Browse files
committed
Remove the ftl helper from fluent
…and use @fluent/dedent instead.
1 parent ab37e18 commit b8ff144

22 files changed

+93
-253
lines changed

fluent/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Remove the `ftl` dedent helper.
6+
7+
The `ftl` dedent helper has moved to its own package, `@fluent/dedent`.
8+
Note that its behavior has changed slightly, too. See the
9+
[README][dedent-readme] for details.
10+
11+
[dedent-readme]: https://www.npmjs.com/package/@fluent/dedent
12+
313
## fluent 0.12.0 (March 26, 2019)
414

515
This release of `fluent` brings support for version 0.9 of the Fluent Syntax

fluent/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"node": ">=8.9.0"
4545
},
4646
"devDependencies": {
47+
"@fluent/dedent": "^0.1.0",
4748
"sinon": "^4.2.2"
4849
}
4950
}

fluent/src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ export { default as FluentBundle } from "./bundle.js";
1111
export { default as FluentResource } from "./resource.js";
1212
export { default as FluentError } from "./error.js";
1313
export { FluentType, FluentNumber, FluentDateTime } from "./types.js";
14-
15-
export { ftl } from "./util.js";

fluent/src/util.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

fluent/test/arguments_test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
67
import { FluentType } from '../src/types';
7-
import { ftl } from '../src/util';
88

99
suite('Variables', function() {
1010
let bundle, errs;
@@ -24,7 +24,7 @@ suite('Variables', function() {
2424
qux = { "a" ->
2525
*[a] Baz Variant A { $num }
2626
}
27-
`);
27+
`);
2828
});
2929

3030
test('can be used in the message value', function() {
@@ -63,7 +63,7 @@ suite('Variables', function() {
6363
foo = { $num ->
6464
*[3] Foo
6565
}
66-
`);
66+
`);
6767
});
6868

6969
test('can be used as a selector', function() {
@@ -79,7 +79,7 @@ suite('Variables', function() {
7979
bundle = new FluentBundle('en-US', { useIsolating: false });
8080
bundle.addMessages(ftl`
8181
foo = { NUMBER($num) }
82-
`);
82+
`);
8383
});
8484

8585
test('can be a positional argument', function() {
@@ -95,7 +95,7 @@ suite('Variables', function() {
9595
bundle = new FluentBundle('en-US', { useIsolating: false });
9696
bundle.addMessages(ftl`
9797
foo = { $arg }
98-
`);
98+
`);
9999
});
100100

101101
test('falls back to argument\'s name if it\'s missing', function() {
@@ -155,7 +155,7 @@ suite('Variables', function() {
155155
bundle = new FluentBundle('en-US', { useIsolating: false });
156156
bundle.addMessages(ftl`
157157
foo = { $arg }
158-
`);
158+
`);
159159
args = {
160160
arg: 'Argument',
161161
};
@@ -176,7 +176,7 @@ suite('Variables', function() {
176176
bundle = new FluentBundle('en-US', { useIsolating: false });
177177
bundle.addMessages(ftl`
178178
foo = { $arg }
179-
`);
179+
`);
180180
args = {
181181
arg: 1
182182
};
@@ -198,7 +198,7 @@ suite('Variables', function() {
198198
bundle = new FluentBundle('en-US', { useIsolating: false });
199199
bundle.addMessages(ftl`
200200
foo = { $arg }
201-
`);
201+
`);
202202
args = {
203203
arg: new Date('2016-09-29')
204204
};
@@ -227,7 +227,7 @@ suite('Variables', function() {
227227
bundle.addMessages(ftl`
228228
foo = { $arg }
229229
bar = { foo }
230-
`);
230+
`);
231231

232232
args = {
233233
// CustomType is a wrapper around the value

fluent/test/attributes_test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
6-
import { ftl } from '../src/util';
77

88
suite('Attributes', function() {
99
let bundle, args, errs;
@@ -27,7 +27,7 @@ suite('Attributes', function() {
2727
ref-bar = { bar.missing }
2828
ref-baz = { baz.missing }
2929
ref-qux = { qux.missing }
30-
`);
30+
`);
3131
});
3232

3333
test('entities with string values and no attributes', function() {
@@ -74,7 +74,7 @@ suite('Attributes', function() {
7474
7575
ref-foo = { foo.attr }
7676
ref-bar = { bar.attr }
77-
`);
77+
`);
7878
});
7979

8080
test('can be referenced for entities with string values', function() {
@@ -121,7 +121,7 @@ suite('Attributes', function() {
121121
ref-bar = { bar.attr }
122122
ref-baz = { baz.attr }
123123
ref-qux = { qux.attr }
124-
`);
124+
`);
125125
});
126126

127127
test('can be referenced for entities with string values', function() {
@@ -178,7 +178,7 @@ suite('Attributes', function() {
178178
}
179179
180180
ref-foo = { foo.attr }
181-
`);
181+
`);
182182
});
183183

184184
test('can be referenced', function() {

fluent/test/bomb_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
6-
import { ftl } from '../src/util';
77

88
suite('Reference bombs', function() {
99
let bundle, args, errs;
@@ -27,7 +27,7 @@ suite('Reference bombs', function() {
2727
lol8 = {lol7} {lol7} {lol7} {lol7} {lol7} {lol7} {lol7} {lol7} {lol7} {lol7}
2828
lol9 = {lol8} {lol8} {lol8} {lol8} {lol8} {lol8} {lol8} {lol8} {lol8} {lol8}
2929
lolz = {lol9}
30-
`);
30+
`);
3131
});
3232

3333
// XXX Protect the FTL Resolver against the billion laughs attack

fluent/test/constructor_test.js

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

33
import assert from 'assert';
44
import sinon from 'sinon';
5+
import ftl from "@fluent/dedent";
56

67
import FluentBundle from '../src/bundle';
7-
import { ftl } from '../src/util';
88

99
suite('FluentBundle constructor', function() {
1010
setup(function() {
@@ -20,7 +20,7 @@ suite('FluentBundle constructor', function() {
2020
const bundle = new FluentBundle('en-US', { useIsolating: false });
2121
bundle.addMessages(ftl`
2222
foo = Foo { 1 }
23-
`);
23+
`);
2424

2525
const msg = bundle.getMessage('foo');
2626
const val = bundle.format(msg, null, errs);
@@ -37,7 +37,7 @@ suite('FluentBundle constructor', function() {
3737
const bundle = new FluentBundle(['de', 'en-US'], { useIsolating: false });
3838
bundle.addMessages(ftl`
3939
foo = Foo { 1 }
40-
`);
40+
`);
4141

4242
const msg = bundle.getMessage('foo');
4343
const val = bundle.format(msg, null, errs);

fluent/test/context_test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
67
import FluentResource from '../src/resource';
7-
import { ftl } from '../src/util';
88

99
suite('Bundle', function() {
1010
let bundle, args, errs;
@@ -19,7 +19,7 @@ suite('Bundle', function() {
1919
bundle.addMessages(ftl`
2020
foo = Foo
2121
-bar = Private Bar
22-
`);
22+
`);
2323
});
2424

2525
test('adds messages', function() {
@@ -32,7 +32,7 @@ suite('Bundle', function() {
3232
test('preserves existing messages when new are added', function() {
3333
bundle.addMessages(ftl`
3434
baz = Baz
35-
`);
35+
`);
3636

3737
assert.equal(bundle._messages.has('foo'), true);
3838
assert.equal(bundle._terms.has('foo'), false);
@@ -46,7 +46,7 @@ suite('Bundle', function() {
4646
test('messages and terms can share the same name', function() {
4747
bundle.addMessages(ftl`
4848
-foo = Private Foo
49-
`);
49+
`);
5050
assert.equal(bundle._messages.has('foo'), true);
5151
assert.equal(bundle._terms.has('foo'), false);
5252
assert.equal(bundle._messages.has('-foo'), false);
@@ -57,7 +57,7 @@ suite('Bundle', function() {
5757
test('does not overwrite existing messages if the ids are the same', function() {
5858
const errors = bundle.addMessages(ftl`
5959
foo = New Foo
60-
`);
60+
`);
6161

6262
// Attempt to overwrite error reported
6363
assert.equal(errors.length, 1);
@@ -73,7 +73,7 @@ suite('Bundle', function() {
7373
test('overwrites existing messages if the ids are the same and allowOverrides is true', function() {
7474
const errors = bundle.addMessages(ftl`
7575
foo = New Foo
76-
`, { allowOverrides: true });
76+
`, { allowOverrides: true });
7777

7878
// No overwrite errors reported
7979
assert.equal(errors.length, 0);
@@ -93,7 +93,7 @@ suite('Bundle', function() {
9393
let resource = FluentResource.fromString(ftl`
9494
foo = Foo
9595
-bar = Bar
96-
`);
96+
`);
9797
bundle.addResource(resource);
9898
});
9999

@@ -149,7 +149,7 @@ suite('Bundle', function() {
149149
err4 =
150150
.attr1 = Attr
151151
.attr2 = {}
152-
`);
152+
`);
153153
});
154154

155155
test('returns true only for public messages', function() {
@@ -176,7 +176,7 @@ suite('Bundle', function() {
176176
bundle.addMessages(ftl`
177177
foo = Foo
178178
-bar = Bar
179-
`);
179+
`);
180180
});
181181

182182
test('returns public messages', function() {

fluent/test/functions_builtin_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
6-
import { ftl } from '../src/util';
77

88
suite('Built-in functions', function() {
99
let bundle;
@@ -15,7 +15,7 @@ suite('Built-in functions', function() {
1515
num-decimal = { NUMBER($arg) }
1616
num-percent = { NUMBER($arg, style: "percent") }
1717
num-bad-opt = { NUMBER($arg, style: "bad") }
18-
`);
18+
`);
1919
});
2020

2121
test('missing argument', function() {
@@ -96,7 +96,7 @@ suite('Built-in functions', function() {
9696
dt-default = { DATETIME($arg) }
9797
dt-month = { DATETIME($arg, month: "long") }
9898
dt-bad-opt = { DATETIME($arg, month: "bad") }
99-
`);
99+
`);
100100
});
101101

102102
test('missing argument', function() {

fluent/test/functions_runtime_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
6-
import { ftl } from '../src/util';
77

88
suite('Runtime-specific functions', function() {
99
let bundle, args, errs;
@@ -24,7 +24,7 @@ suite('Runtime-specific functions', function() {
2424
bundle.addMessages(ftl`
2525
foo = { CONCAT("Foo", "Bar") }
2626
bar = { SUM(1, 2) }
27-
`);
27+
`);
2828
});
2929

3030
test('works for strings', function() {

fluent/test/functions_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
import assert from 'assert';
4+
import ftl from "@fluent/dedent";
45

56
import FluentBundle from '../src/bundle';
6-
import { ftl } from '../src/util';
77

88
suite('Functions', function() {
99
let bundle, args, errs;
@@ -17,7 +17,7 @@ suite('Functions', function() {
1717
bundle = new FluentBundle('en-US', { useIsolating: false });
1818
bundle.addMessages(ftl`
1919
foo = { MISSING("Foo") }
20-
`);
20+
`);
2121
});
2222

2323
test('falls back to the name of the function', function() {
@@ -47,7 +47,7 @@ suite('Functions', function() {
4747
pass-attr = { IDENTITY(foo.attr) }
4848
pass-variable = { IDENTITY($var) }
4949
pass-function-call = { IDENTITY(IDENTITY(1)) }
50-
`);
50+
`);
5151
});
5252

5353
// XXX Gracefully handle wrong argument types passed into FTL Functions

0 commit comments

Comments
 (0)