KScript in pages
Pages run on the same interpreter as scripts, so every KScript.Core command and method works in them. Pages also get KScript.IO, KScript.Markdown and KScript.Web without importing them: @read_json, @read_text, @read_markdown (which gives html, title and meta), @files, @exists and @markdown. Import other packages at the top of the page, as in a script:
<import package="KScript.Math" as="math" />
<p>The square root of 2 is { @math.sqrt(2) }</p><import path> at the top of a page gives it a script's top-level functions and const values. as="text" (then @text.shout(...)) and names="shout" work as they do in scripts:
<import path="lib/text.kscript" />
<h1>{ @shout('welcome') }</h1>Files, errors and safety
Paths start in the site folder and can't leave it, and rendering a page can only read files. A live action in a controller view may write when http.write_files allows it.
Errors show the file and line, and endless loops and runaway recursion are stopped. In the production environment (kscript serve --env production), a visitor gets a plain 500 page instead, and the message, file and line go to the server's log only.