Skip to content

Commit edff7f1

Browse files
committed
Add support to expr strings with double quotes
1 parent 38bae98 commit edff7f1

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`Hello "World"`
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This file was generated by reqlang-expr-tspl
2+
import * as ReqlangExpr from "@reqlang-expr-tspl/runtime";
3+
4+
const expression: ReqlangExpr.Expression = (ctx) => {
5+
return "Hello \"World\"";
6+
};
7+
8+
const args = ReqlangExpr.getArgs();
9+
10+
const env = new ReqlangExpr.Env(
11+
args.vars,
12+
args.prompts,
13+
args.secrets,
14+
args.client
15+
);
16+
17+
const context = {
18+
env,
19+
builtins: ReqlangExpr.builtinFns,
20+
};
21+
22+
const value = expression(context);
23+
24+
console.log(JSON.stringify(value));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"Hello \"World\""

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn transpile_expr(expr: &Expr) -> String {
117117
}
118118
}
119119
Expr::String(expr_string) => {
120-
format!("\"{}\"", expr_string.0)
120+
format!("\"{}\"", expr_string.0.replace("\"", r#"\""#))
121121
}
122122
Expr::Error => todo!(),
123123
}

0 commit comments

Comments
 (0)