Cite.Placeholder (Cite v0.1.0)

Copy Markdown View Source

{name} placeholders in question text, and the backticked paths they expand to.

A policy's questions name what they look at by role ({passage}, {household}); Cite replaces each with its path. The policy's compile-time checks use names/1 and name?/1; Cite.Wire uses instructions/4. Internal.

Summary

Functions

text with every placeholder replaced by its backticked path.

The wire instructions for a question and its focus (nil for none): both texts expanded, plus what to read. The placeholders of both, in order of first use, become inspect when there is one and compare when there are several; with none, it is compare over fallback.

Whether name can be a placeholder: a word of letters, digits, and _. Such a name is also safe in a path.

Each placeholder name in text, once, in order of first use. Given a list (a question and its focus, where the focus may be nil), the names across all of them.

Functions

expand(text, paths)

@spec expand(String.t(), %{required(String.t()) => String.t()}) :: String.t()

text with every placeholder replaced by its backticked path.

instructions(text, focus, paths, fallback)

@spec instructions(
  String.t(),
  String.t() | nil,
  %{required(String.t()) => String.t()},
  [String.t()]
) ::
  map()

The wire instructions for a question and its focus (nil for none): both texts expanded, plus what to read. The placeholders of both, in order of first use, become inspect when there is one and compare when there are several; with none, it is compare over fallback.

name?(name)

@spec name?(String.t()) :: boolean()

Whether name can be a placeholder: a word of letters, digits, and _. Such a name is also safe in a path.

names(texts)

@spec names(String.t() | [String.t() | nil]) :: [String.t()]

Each placeholder name in text, once, in order of first use. Given a list (a question and its focus, where the focus may be nil), the names across all of them.