Skip to content

Commit 405f875

Browse files
committed
feat(export): add littlehorse chaining stubs
1 parent a5faffb commit 405f875

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/export-littlehorse.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,21 @@ function renderStatements(statements, indentSize) {
185185
if (statement.type === "if") {
186186
lines.push(`${indent}wf.doIf(/* ${formatCondition(statement.condition)} */, ifBody -> {`);
187187
lines.push(...renderStatements(statement.then || [], indentSize + 2));
188-
lines.push(`${indent}});`);
188+
lines.push(`${indent}})`);
189189

190-
for (const branch of statement.elseIf || []) {
191-
lines.push(`${indent}// else if ${formatCondition(branch.condition)} (map to doElseIf)`);
190+
const elseIfBranches = statement.elseIf || [];
191+
for (const branch of elseIfBranches) {
192+
lines.push(`${indent}.doElseIf(/* ${formatCondition(branch.condition)} */, elseIfBody -> {`);
192193
lines.push(...renderStatements(branch.then || [], indentSize + 2));
194+
lines.push(`${indent}})`);
193195
}
194196

195197
if (statement.else && (statement.else.body || []).length > 0) {
196-
lines.push(`${indent}// else (map to doElse)`);
198+
lines.push(`${indent}.doElse(elseBody -> {`);
197199
lines.push(...renderStatements(statement.else.body || [], indentSize + 2));
200+
lines.push(`${indent}});`);
201+
} else {
202+
lines.push(`${indent};`);
198203
}
199204
continue;
200205
}

0 commit comments

Comments
 (0)