Skip to content

Commit

Permalink
Set ssr true at the start
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpita-Jaiswal committed Oct 30, 2023
1 parent 9911f3b commit f6ab278
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fastn-js/src/ssr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ pub fn ssr(ast: &[fastn_js::Ast]) -> String {
parenti0.setProperty(fastn_dom.PropertyKind.Height, fastn_dom.Resizing.FillContainer, inherited);
main(parenti0);
}};
fastn_virtual.ssr(main_wrapper);", fastn_js::to_js(ast,
"foo"));
fastn_virtual.ssr(main_wrapper);", fastn_js::to_js(ast,"foo"));
ssr_str(&js)
}

pub fn ssr_with_js_string(package_name: &str, js: &str) -> String {
let js = format!("
let __fastn_package_name__ = \"{}\";\n{}
let __fastn_package_name__ = \"{}\";\nssr = true;\n{}
let main_wrapper = function(parent) {{
let parenti0 = fastn_dom.createKernel(parent, fastn_dom.ElementKind.Column);
parenti0.setProperty(fastn_dom.PropertyKind.Width, fastn_dom.Resizing.FillContainer, inherited);
Expand Down
1 change: 1 addition & 0 deletions ftd/src/js/ftd_test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fn p(s: &str, t: &str, fix: bool, manual: bool, script: bool, file_location: &st
<script>
{dummy_package_data}
{all_js}
ssr = true;
{js_ftd_script}
{js_document_script}
fastn_virtual.ssr(main);
Expand Down
4 changes: 4 additions & 0 deletions ftd/t/assets/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ function show(a) {
function greeting(){
return "Namaste!";
}

function number() {
return 12;
}
22 changes: 22 additions & 0 deletions ftd/t/js/70-external-js.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- ftd.text: $greetingfn()

-- integer num: $numberfn()

-- ftd.integer: $num

/-- ftd.text: Hello if >= 10
js: ../../t/assets/test.js
if: { num > 10 }



-- string greetingfn():
js: ../../t/assets/test.js

greeting()


-- integer numberfn():
js: ../../t/assets/test.js

numbers()
119 changes: 119 additions & 0 deletions ftd/t/js/70-external-js.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f6ab278

Please sign in to comment.