Copperlace Examples
These standalone rule files show different ways to combine rules, random choices, bindings, context defaults, and processors. Random choices can produce different output on each render.
Run examples from rust-core/ with:
cargo run --bin copperlace -- render --config ../examples/character_scene.conf --rule origin
Files
character_scene.conf-
Short fiction or RPG flavor text. Demonstrates bindings, context defaults,
article,possessive,present_participle, andsentence. culture_names.conf-
Procedural culture and naming patterns. Demonstrates phonetic profiles, first names, family names, place names, accented vowels, and bindings.
item_card.conf-
Game item card copy. Demonstrates reusable item bindings,
titlecase,past_tense,pluralize, andpresent_participle. gendered_pronouns.conf-
Character text with consistent pronouns. Demonstrates bindings and male, female, and neutral lizard pronouns, plus
present_participle. fish_report.conf-
Fish observation copy. Demonstrates importing a HOCON fragment with
include classpath("fragments/fish_facts.conf"), object merging, dotted rules, bindings,article,sentence, andtitlecase. fragments/fish_facts.conf-
Reusable fish vocabulary imported by
fish_report.conf. item_json.conf-
JSON item data. Demonstrates JSON-safe quoted strings, bindings, scalar values,
slug,ordinal,article,past_tense,pluralize, andpresent_participle. structured_item.conf-
Structured item data. Demonstrates native object-valued structured rendering, nested objects, arrays, bindings, and processors without hand-assembling JSON as text.
product_blurb.conf-
Product or marketing microcopy. Demonstrates multiple render rules plus
titlecase,sentence,article,quote,pluralize, andslug. proverbs.conf-
Short proverb-style sayings. Demonstrates weighted templates, bindings, context defaults,
sentence, andarticle. recursive_path.conf-
Recursive route text. Demonstrates opt-in limited recursion with
--max-recursion-depth. rival_duel.conf-
Duel prompt text. Demonstrates strict unique choice calls with
{rule!}so two fighters draw distinct entries from one choice rule. release_note.conf-
Changelog-style output. Demonstrates
past_tense,article,ordinal,pluralize,possessive, and binding reuse. quest_log.conf-
Quest/task text. Demonstrates
singularize,article,possessive,present_participle,pluralize, and context defaults.
Try alternate rules where available:
cargo run --bin copperlace -- render --config ../examples/product_blurb.conf --rule headline
cargo run --bin copperlace -- render --config ../examples/product_blurb.conf --rule tagline
cargo run --bin copperlace -- render --config ../examples/product_blurb.conf --rule slug
cargo run --bin copperlace -- render --config ../examples/proverbs.conf --rule origin
cargo run --bin copperlace -- render --config ../examples/proverbs.conf --rule short
cargo run --bin copperlace -- render --config ../examples/recursive_path.conf --max-recursion-depth 3
cargo run --bin copperlace -- render --config ../examples/rival_duel.conf --rule origin
cargo run --bin copperlace -- render --config ../examples/gendered_pronouns.conf --rule origin
cargo run --bin copperlace -- render --config ../examples/gendered_pronouns.conf --rule profile
cargo run --bin copperlace -- render --config ../examples/fish_report.conf --rule origin
cargo run --bin copperlace -- render --config ../examples/item_json.conf --rule origin
cargo run --bin copperlace -- render --config ../examples/structured_item.conf --rule origin
cargo run --bin copperlace -- render --config ../examples/quest_log.conf --rule objective
cargo run --bin copperlace -- render --config ../examples/culture_names.conf --rule first_name
cargo run --bin copperlace -- render --config ../examples/culture_names.conf --rule family_name
cargo run --bin copperlace -- render --config ../examples/culture_names.conf --rule place_name
item_json.conf shows the older pattern of generating JSON as text with
explicit quoting. structured_item.conf uses an object-valued origin rule, so
the CLI infers structured output and writes formatted JSON by default. Shared
generated item values live in context defaults so object fields do not depend
on sibling field evaluation order:
cargo run --bin copperlace -- render --config ../examples/structured_item.conf
cargo run --bin copperlace -- render --config ../examples/structured_item.conf --compact-json
cargo run --bin copperlace -- render --config ../examples/structured_item.conf --count 2
cargo run --bin copperlace -- render --config ../examples/structured_item.conf --set itemRarity=mythic
recursive_path.conf intentionally calls path_tail from itself. Rendering it
without --max-recursion-depth fails with CircularRuleReference; rendering
with --max-recursion-depth 3 produces a finite route and cuts off the next
recursive call with an empty string.
fish_report.conf imports fragments/fish_facts.conf through HOCON classpath
include syntax. File-loaded configs search the config file’s parent directory
first, then the process current directory, so the include works when rendering
the example from outside examples/.
Interactive Examples
Source config