@weborigami/language 0.2.10 → 0.2.12
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/main.js +1 -1
- package/package.json +6 -6
- package/src/compiler/isOrigamiFrontMatter.js +26 -0
- package/src/compiler/origami.pegjs +56 -10
- package/src/compiler/parse.js +623 -349
- package/src/compiler/parserHelpers.js +107 -3
- package/src/runtime/errors.js +19 -2
- package/src/runtime/evaluate.js +1 -9
- package/src/runtime/ops.js +33 -4
- package/src/runtime/taggedTemplateIndent.js +10 -5
- package/test/compiler/codeHelpers.js +1 -1
- package/test/compiler/parse.test.js +115 -43
- package/test/runtime/expressionObject.test.js +2 -2
- package/test/runtime/ops.test.js +23 -0
- package/test/runtime/taggedTemplateIndent.test.js +6 -6
- package/src/runtime/taggedTemplate.js +0 -9
- package/test/runtime/taggedTemplate.test.js +0 -10
|
@@ -3,13 +3,13 @@ import { describe, test } from "node:test";
|
|
|
3
3
|
import indent from "../../src/runtime/taggedTemplateIndent.js";
|
|
4
4
|
|
|
5
5
|
describe("taggedTemplateIndent", () => {
|
|
6
|
-
test("joins strings and values together if template isn't a block template", () => {
|
|
7
|
-
const result = indent`a ${"b"} c`;
|
|
6
|
+
test("joins strings and values together if template isn't a block template", async () => {
|
|
7
|
+
const result = await indent`a ${"b"} c`;
|
|
8
8
|
assert.equal(result, "a b c");
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
test("removes first and last lines if template is a block template", () => {
|
|
12
|
-
const actual = indent`
|
|
11
|
+
test("removes first and last lines if template is a block template", async () => {
|
|
12
|
+
const actual = await indent`
|
|
13
13
|
<p>
|
|
14
14
|
Hello, ${"Alice"}!
|
|
15
15
|
</p>
|
|
@@ -22,12 +22,12 @@ describe("taggedTemplateIndent", () => {
|
|
|
22
22
|
assert.equal(actual, expected);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
test("indents all lines in a block substitution", () => {
|
|
25
|
+
test("indents all lines in a block substitution", async () => {
|
|
26
26
|
const lines = `
|
|
27
27
|
Line 1
|
|
28
28
|
Line 2
|
|
29
29
|
Line 3`.trimStart();
|
|
30
|
-
const actual = indent`
|
|
30
|
+
const actual = await indent`
|
|
31
31
|
<main>
|
|
32
32
|
${lines}
|
|
33
33
|
</main>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Default JavaScript tagged template function splices strings and values
|
|
2
|
-
// together.
|
|
3
|
-
export default function taggedTemplate(strings, ...values) {
|
|
4
|
-
let result = strings[0];
|
|
5
|
-
for (let i = 0; i < values.length; i++) {
|
|
6
|
-
result += values[i] + strings[i + 1];
|
|
7
|
-
}
|
|
8
|
-
return result;
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, test } from "node:test";
|
|
3
|
-
import taggedTemplate from "../../src/runtime/taggedTemplate.js";
|
|
4
|
-
|
|
5
|
-
describe("taggedTemplate", () => {
|
|
6
|
-
test("joins strings and values together", () => {
|
|
7
|
-
const result = taggedTemplate`a ${"b"} c`;
|
|
8
|
-
assert.equal(result, "a b c");
|
|
9
|
-
});
|
|
10
|
-
});
|