Rendering
Choose fragment or document rendering deliberately and render each completed view at the application boundary.
On this page
Fragments
fragment { ... } composes sibling nodes without adding a wrapper. Render.toString serializes exactly those siblings and does not prepend a doctype.
let nodes = [ span { "One" }; span { "Two" } ]
let rendered =
fragment {
strong { "Items: " }
yield! nodes
}
|> Render.toString
// <strong>Items: </strong><span>One</span><span>Two</span>Migration: replace Html.fragment nodes with fragment { yield! nodes }. Replace title "Account" or titleBuilder { ... } with title { "Account" }.
Documents
Render.toHtmlDocString prepends <!DOCTYPE html> and is intended for a complete HTML document.
let responseBody =
html {
_lang "en"
head { title { "Account" } }
body { main { h1 { "Account" } } }
}
|> Render.toHtmlDocStringApplication boundaries
FSharp.ViewEngine has no web-framework dependency. Pass the resulting string to your framework's normal HTML response API. See the Giraffe integration for a complete server example.