Import std.text.template
Templates
class
Public Class Templates
Templates by name, which render each other as partials: {{> header}} is the template named "header". One whose name ends with ".html" or ".htm" escapes its values for HTML, as a partial too, and so do the partials it renders, whatever their names.
Examples
Local site = Templates()
Try site.Add("header", r"<h1>{{title}}</h1>")
Try site.Add("page", r"{{> header}}<p>{{body}}</p>")
Local data = Value.Object()
data["title"] = Value("Hi")
data["body"] = Value("there")
Expect((Try site.Render("page", data)) == "<h1>Hi</h1><p>there</p>")-
A new Templates, with none added.
-
Adds the template that
textis asname, in place of one that has thenamealready. Throws a FormatError of BAD_TEMPLATE where thetextisn't one, which says the template'sname, the line, and the column. -
Whether it has a template of the
name. -
The template of the
name, filled from a Value, whose Object's keys are the names the tags give. Throws a FormatError of MISSING_VALUE where it has no template of thename, or of a partial's, and of OTHER for partials more than 1000 deep inside each other. -
The template of the
name, filled from the Value that Save makes ofdata. Panics, as Save does, fordatathat nests more than 256 levels deep.
Report an issue with this page or with FutureBlitz on GitHub.