re-allow multiple statements but must use a return

This commit is contained in:
Ruben Fiszel
2023-05-14 15:02:22 +02:00
parent 7fb71fafdb
commit 42a73bd701
2 changed files with 7 additions and 1 deletions
+6 -1
View File
@@ -216,13 +216,18 @@ async function resource(path) {{
(String::new(), String::new())
};
let f = if expr.contains("return ") {
expr.to_string()
} else {
format!("return {expr}")
};
let code = format!(
r#"
{api_code}
{}
{by_id_code}
(async () => {{
return {expr};
{f};
}})()
"#,
env.into_iter()
@@ -39,5 +39,6 @@
<b>resource(path)</b>: the function returning the resource at a given path as an object
</li>
</ul>
If using multiple statements, the last statement shall finish with a return. e.g: `return x`
</div>
{/if}