This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Epiphany/vendor/codex/codex-rs/utils/template
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-23 23:20:16 +01:00
..
src Vendor Codex and land Phase 1 Epiphany state slice 2026-04-23 23:20:16 +01:00
BUILD.bazel Vendor Codex and land Phase 1 Epiphany state slice 2026-04-23 23:20:16 +01:00
Cargo.toml Vendor Codex and land Phase 1 Epiphany state slice 2026-04-23 23:20:16 +01:00
README.md Vendor Codex and land Phase 1 Epiphany state slice 2026-04-23 23:20:16 +01:00

codex-utils-template

Small, strict string templating for prompt and text assets.

Supported syntax:

  • {{ name }} placeholder interpolation
  • {{{{ for a literal {{
  • }}}} for a literal }}

The library is intentionally strict:

  • parsing fails on malformed placeholders
  • rendering fails on missing values
  • rendering fails on duplicate values
  • rendering fails on extra values not used by the template

Example

use codex_utils_template::Template;
use codex_utils_template::render;

let template = Template::parse(
    "Hello, {{ name }}.\nLiteral braces: {{{{ and }}}}.\nMode: {{ mode }}",
)?;

let rendered = template.render([
    ("name", "Codex"),
    ("mode", "strict"),
])?;

assert_eq!(
    rendered,
    "Hello, Codex.\nLiteral braces: {{ and }}.\nMode: strict"
);

let one_shot = render("Hi {{ who }}!", [("who", "there")])?;
assert_eq!(one_shot, "Hi there!");
# Ok::<(), Box<dyn std::error::Error>>(())