Import std.text.template
std.text.template
std.text.template: Mustache-style templates, which a Value fills, or a Struct, a Class, or a Map, through the Value that Save makes of it. A template is text with tags in "{{ }}", each filled in when it's rendered: {{name}} gives a value, the blocks {{#each name}}, {{#if name}}, and {{#unless name}} go over or test one, with an {{else}} for when there's nothing, {{> name}} renders another template there, and {{! }} is a comment. A value can take a format spec, as {{price:.2}} does, as interpolation's "{price:.2}" would. A block's tag alone on its line takes the line with it. A template for HTML escapes its values.
std/text/template.fb
Types
Template
class
Public Class Template
A template, read once, which Render fills from what it's given each time.
-
The template that
textis, which escapes its values for HTML withhtml. Throws a FormatError of BAD_TEMPLATE where thetextisn't one, which says the line and column. -
The template, filled from a Value, whose Object's keys are the names the tags give. Throws a FormatError of MISSING_VALUE at a partial, which only Templates have.
-
The template, filled from the Value that Save makes of
data: a Struct's or Class's Fields by name, a Map's keys, and the rest as Save has them. Panics, as Save does, fordatathat nests more than 256 levels deep.
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.
-
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.