# eb-local.sites ::::{zig:module} eb-local.sites :file: src/sites.zig :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig Site file templates, built into the program or kept by a site in a file: `eb-local site` lists the built-in ones, and renders and installs either kind. A template is TOML with {{name}} placeholders, which --set name=value must fill, and {{name:default}} ones, which take the default unless set. Values go inside TOML strings, so a value with a quote, a backslash or a control character is refused. :::: ## Types ::::{zig:type} eb-local.sites.Template :signature: pub const Template = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L12 A site file template: the name `eb-local site` takes, and its TOML text with placeholders. :::{zig:field} eb-local.sites.Template.name :signature: name: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L12 ::: :::{zig:field} eb-local.sites.Template.text :signature: text: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L12 ::: :::: ::::{zig:type} eb-local.sites.Set :signature: pub const Set = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L27 One `--set NAME=VALUE`: the placeholder it fills, and its value. :::{zig:field} eb-local.sites.Set.name :signature: name: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L27 ::: :::{zig:field} eb-local.sites.Set.value :signature: value: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L27 ::: :::: ::::{zig:type} eb-local.sites.Diagnostic :signature: pub const Diagnostic = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L31 Why a `--set` or a template was refused, filled in when `error.Invalid` is returned. :::{zig:field} eb-local.sites.Diagnostic.message :signature: message: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L31 ::: :::: ## Error sets ::::{zig:errorset} eb-local.sites.Error :signature: pub const Error = error{Invalid} || Allocator.Error :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L35 `error.Invalid` when a `--set` or a template is refused, with the reason in the `Diagnostic`. :::: ## Functions :::{zig:function} eb-local.sites.find :signature: pub fn find(name: []const u8) ?Template :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L21 The built-in template called `name`, or null when there is none. ::: :::{zig:function} eb-local.sites.validValue :signature: pub fn validValue(v: []const u8) bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L49 A value that stays one TOML string: printable, no quote or backslash. ::: :::{zig:function} eb-local.sites.parseSet :signature: pub fn parseSet(a: Allocator, arg: []const u8, d: *Diagnostic) Error!Set :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L56 Parse NAME=VALUE. ::: :::{zig:function} eb-local.sites.placeholders :signature: pub fn placeholders(a: Allocator, text: []const u8) Allocator.Error![]const []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L66 The names a template's placeholders use, each once, in order. ::: :::{zig:function} eb-local.sites.render :signature: pub fn render(a: Allocator, t: Template, sets: []const Set, d: *Diagnostic) Error![]const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L91 The template with every placeholder filled. A --set naming no placeholder, or a required placeholder left unset, is an error. ::: ## Constants :::{zig:constant} eb-local.sites.all :signature: pub const all = ... :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/sites.zig#L15 The built-in templates, for no particular site; a site keeps its own in a file. :::