Skip to content

Commit f923c1d

Browse files
committed
feat: Uppercase Twig option
BREAKING CHANGE: Uppercase Twig option to align with Twig.js documentation.
1 parent 6f2b9fc commit f923c1d

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Twig from "twig";
2626
import { twigDrupalString } from "twig-drupal-string";
2727
2828
twigDrupalString({
29-
twig: Twig,
29+
Twig,
3030
files: ["strings.yaml"],
3131
});
3232
@@ -76,7 +76,7 @@ Set the `watch` options:
7676

7777
```js
7878
twigDrupalString({
79-
twig: Twig,
79+
Twig,
8080
files: ["strings.yaml"],
8181
watch: true,
8282
});

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import YAML from "yaml";
55
/**
66
* @param {import("./types.d.ts").Options} options
77
*/
8-
export function twigDrupalString({ twig, files, watch = false }) {
8+
export function twigDrupalString({ Twig, files, watch = false }) {
99
let translations = getTranslations(files);
1010

1111
/** @type {Set<string>} */
@@ -69,8 +69,8 @@ export function twigDrupalString({ twig, files, watch = false }) {
6969
return string;
7070
};
7171

72-
twig.extendFilter("t", trans);
73-
twig.extendFilter("trans", trans);
72+
Twig.extendFilter("t", trans);
73+
Twig.extendFilter("trans", trans);
7474
}
7575

7676
/**

lib/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Twig from "twig";
22

33
type Options = {
44
/** Twig engine instance */
5-
twig: typeof Twig;
5+
Twig: typeof Twig;
66

77
/** Paths to translation string files */
88
files: string[];

test/index.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import assert from "node:assert/strict";
22
import test from "node:test";
33

4-
import twig from "twig";
4+
import Twig from "twig";
55

66
import { twigDrupalString } from "../lib/index.js";
77

8-
twigDrupalString({ twig, files: ["./test/strings.yaml"] });
8+
twigDrupalString({ Twig, files: ["./test/strings.yaml"] });
99

1010
test("basic", async (t) => {
1111
const expected = `<h1>Hello world</h1>`;
1212

1313
await t.test("t", () => {
1414
const data = `<h1>{{ 'welcome'|t }}</h1>`;
15-
const result = twig.twig({ data }).render();
15+
const result = Twig.twig({ data }).render();
1616

1717
assert.equal(result, expected);
1818
});
1919

2020
await t.test("trans", () => {
2121
const data = `<h1>{{ 'welcome'|trans }}</h1>`;
22-
const result = twig.twig({ data }).render();
22+
const result = Twig.twig({ data }).render();
2323

2424
assert.equal(result, expected);
2525
});
@@ -30,14 +30,14 @@ test("placeholder", async (t) => {
3030

3131
await t.test("t", () => {
3232
const data = `<h1>{{ 'greeting'|t({'@name': 'world'}) }}</h1>`;
33-
const result = twig.twig({ data }).render();
33+
const result = Twig.twig({ data }).render();
3434

3535
assert.equal(result, expected);
3636
});
3737

3838
await t.test("trans", () => {
3939
const data = `<h1>{{ 'greeting'|trans({'@name': 'world'}) }}</h1>`;
40-
const result = twig.twig({ data }).render();
40+
const result = Twig.twig({ data }).render();
4141

4242
assert.equal(result, expected);
4343
});
@@ -48,14 +48,14 @@ test("not found", async (t) => {
4848

4949
await t.test("t", () => {
5050
const data = `<h1>{{ 'goodbye'|t }}</h1>`;
51-
const result = twig.twig({ data }).render();
51+
const result = Twig.twig({ data }).render();
5252

5353
assert.equal(result, expected);
5454
});
5555

5656
await t.test("trans", () => {
5757
const data = `<h1>{{ 'goodbye'|trans }}</h1>`;
58-
const result = twig.twig({ data }).render();
58+
const result = Twig.twig({ data }).render();
5959

6060
assert.equal(result, expected);
6161
});
@@ -66,14 +66,14 @@ test("no default", async (t) => {
6666

6767
await t.test("t", () => {
6868
const data = `<h1>{{ 'see.ya'|t }}</h1>`;
69-
const result = twig.twig({ data }).render();
69+
const result = Twig.twig({ data }).render();
7070

7171
assert.equal(result, expected);
7272
});
7373

7474
await t.test("trans", () => {
7575
const data = `<h1>{{ 'see.ya'|trans }}</h1>`;
76-
const result = twig.twig({ data }).render();
76+
const result = Twig.twig({ data }).render();
7777

7878
assert.equal(result, expected);
7979
});

0 commit comments

Comments
 (0)