Repository navigation
v4.3.0
WebFluent as a template engine, from Rust first and from Node: templates
load once and render on every request, spread over files, with your own
data types, and untrusted data cannot put script in the page.
Security
- A URL from the data that a browser would run is dropped. The template
engine wroteLink("Pay", to: url)withurl = "javascript:…"as a live
link, and the static paint did the same for anImage,Video,
Audio, aSidebar.Itemand anElementattribute. Every URL attribute
now goes through the scheme check the browser build applies.
New, in Rust
Template::from_files,from_dirandfrom_sources: one template from
several files — components, themes, types and constants shared — each
finding naming its file.pages()lists the pages andpage(name)picks
the one to render.- Data is any
serde::Serializevalue — your own structs — as well as a
serde_json::Value. render_htmlwrites a<title>from the page's, filled from the data,
andwith_langsets<html lang>(anddir="rtl"for an RTL language).with_pdf(PdfConfig)andwith_slides(SlidesConfig)set page size,
margins and fonts;PdfConfig,PdfMarginsandSlidesConfigare
exported at the crate root.- A
Templateparses and checks once and shares the result:Cloneis
cheap and it isSend + Sync, for a server's state. - The
clifeature (default) holds thewfcommand's own dependencies;
default-features = falsebuilds the engine without them — 43 crates
instead of 62. cargo run --example invoicerenders a directory of templates to HTML,
a fragment and a PDF.
New, in Node
renderHtmlAsync,renderHtmlFragmentAsync,renderPdfAsyncand
renderSlidesAsyncrender without blocking the event loop.Template.fromDir(dir),page(name)andwithLang(lang), as in Rust.- The data goes to
wfover stdin and a PDF comes back on stdout: nothing
is written to disk per render. wf rendertakes a directory,--pageand--lang.
Fixed
- A template's components are drawn in its PDF and slides. The PDF
path left every component call out, so an invoice's line items were
missing; it also left a function or method call unevaluated —
format(price, .currency)drew nothing. constanddatafiles are in scope in a template.Text("{LIMIT}")
rendered empty.
Full Changelog: v4.2.1...v4.3.0