Skip to main content

copperlace/
lib.rs

1//! Copperlace text renderer.
2//!
3//! Copperlace compiles configuration into named rules and renders one rule at a
4//! time. Templates can reference other rules, make random choices, bind values
5//! for the duration of one render, use lazy `context` defaults, and transform
6//! rendered text with processors.
7//! Rust callers can also provide initial render context values when rendering a
8//! rule.
9//!
10//! For repeated renders from the same config, use [`Copperlace`] or [`RuleSet`]
11//! so the config is parsed and compiled once. For one-off rendering, use
12//! [`render_file`] or [`render_str`].
13
14pub mod config;
15#[cfg(not(target_arch = "wasm32"))]
16pub mod ffi;
17mod processors;
18pub mod render;
19#[cfg(target_arch = "wasm32")]
20mod wasm;
21
22pub use config::{
23    ConfigError, Copperlace, render_file, render_file_inferred, render_file_inferred_with_context,
24    render_file_inferred_with_context_and_options, render_file_structured,
25    render_file_structured_with_context, render_file_structured_with_context_and_options,
26    render_file_with_context, render_file_with_context_and_options, render_str,
27    render_str_inferred, render_str_inferred_with_context,
28    render_str_inferred_with_context_and_options, render_str_structured,
29    render_str_structured_with_context, render_str_structured_with_context_and_options,
30    render_str_with_context, render_str_with_context_and_options, ruleset_from_file,
31    ruleset_from_str,
32};
33pub use render::{
34    CopperlaceNumber, CopperlaceValue, Processor, ProcessorRegistry, RenderContext, RenderError,
35    RenderOptions, RuleSet, StructuredArrayEntry, StructuredNode, TextGeneratorNode, processor,
36    render_config_rule, render_config_rule_structured, render_config_rule_structured_with_context,
37    render_config_rule_structured_with_context_and_options, render_config_rule_with_context,
38    render_config_rule_with_context_and_options,
39};