If i understand correctly, you want to build you xhtml with Opa, but instead of serving, print it into files?
We have 2 functions for that :
The differences between those 2 functions, is that the first one will not generate the associated opa js code.
Then you can write the resulting string into an HTML file on disk.
Note that we do not provide any method to write a file in disk in our stdlib.
You have to use the bsl system for that :
write = %%BslFile.of_string%%
A small example :
static.opa
write = %%BslFile.of_string%%
xhtml_page(num:int) =
<p>Page {num}</p>
pages = [1, 2, 3, 4, 5]
do List.iter(i ->
xhtml_content = xhtml_page(i)
string_content = Xhtml.serialize_as_standalone_html(xhtml_content)
write("{i}.html", string_content)
, pages)
Compile and run : opa static.opa --
This will generate 5 html pages.
xhtml_page
(as{Random.int num}
) ? Is there a way to ensure that the generated page will not contain some JavaScript code which will try to communicate with the server ? – Marquez