1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! # Description
//!
//! This is a string template crate.
//! Instead of requiring a complete set of inputs (such as via a `struct`, a `HashMap`, or a JSON object) to be available,
//! the templates from this crate would send queries (which would usually be the names of the variables) to a function
//! (called "responder") to get the value of each query.
//!
//! # Usage Examples
//!
//! **Example 1:** Lazily parse template
//!
//! ```
//! # #[cfg(not(feature = "std"))] fn main() {}
//! # #[cfg(feature = "std")] fn main() {
//! # use pretty_assertions::assert_eq;
//! let system = lazy_template::simple_curly_braces();
//! let template = system.lazy_parse("{name} is a {age} years old {descriptor}");
//! let alice_info = template
//! .to_string(|query| match query {
//! "name" => Ok("Alice"),
//! "age" => Ok("20"),
//! "descriptor" => Ok("girl"),
//! _ => Err(format!("Can't answer {query}")),
//! })
//! .unwrap();
//! let bob_info = template
//! .to_string(|query| match query {
//! "name" => Ok("Bob"),
//! "age" => Ok("32"),
//! "descriptor" => Ok("man"),
//! _ => Err(format!("Can't answer {query}")),
//! })
//! .unwrap();
//! assert_eq!(alice_info, "Alice is a 20 years old girl");
//! assert_eq!(bob_info, "Bob is a 32 years old man");
//! # }
//! ```
//!
//! _see more:_ [`mod@simple_curly_braces`], [`lazy_parse`](crate::TemplateSystem::lazy_parse).
//!
//! **Example 2:** Eagerly parse template:
//!
//! ```
//! # #[cfg(not(feature = "std"))] fn main() {}
//! # #[cfg(feature = "std")] fn main() {
//! # use pretty_assertions::assert_eq;
//! let system = lazy_template::simple_curly_braces();
//! let parsed_template = system
//! .eager_parse::<Vec<_>>("{name} is a {age} years old {descriptor}")
//! .unwrap();
//! let alice_info = parsed_template
//! .to_template()
//! .to_string(|query| match query {
//! "name" => Ok("Alice"),
//! "age" => Ok("20"),
//! "descriptor" => Ok("girl"),
//! _ => Err(format!("Can't answer {query}")),
//! })
//! .unwrap();
//! let bob_info = parsed_template
//! .to_template()
//! .to_string(|query| match query {
//! "name" => Ok("Bob"),
//! "age" => Ok("32"),
//! "descriptor" => Ok("man"),
//! _ => Err(format!("Can't answer {query}")),
//! })
//! .unwrap();
//! assert_eq!(alice_info, "Alice is a 20 years old girl");
//! assert_eq!(bob_info, "Bob is a 32 years old man");
//! # }
//! ```
//!
//! _see more:_ [`mod@simple_curly_braces`], [`eager_parse`](crate::TemplateSystem::eager_parse).
//!
pub use EnclosedTemplateParser;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;