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
#[cfg(test)]
#[macro_use]
extern crate gtmpl_derive;
extern crate gtmpl_value;
extern crate itertools;
#[macro_use]
extern crate lazy_static;
mod exec;
#[doc(inlne)]
pub mod funcs;
mod lexer;
mod node;
mod parse;
mod print_verb;
mod printf;
mod template;
mod utils;
#[doc(inline)]
pub use crate::template::Template;
#[doc(inline)]
pub use crate::exec::Context;
#[doc(inline)]
pub use gtmpl_value::Func;
#[doc(inline)]
pub use gtmpl_value::from_value;
pub use gtmpl_value::Value;
pub fn template<T: Into<Value>>(template_str: &str, context: T) -> Result<String, String> {
let mut tmpl = Template::default();
tmpl.parse(template_str)?;
tmpl.render(&Context::from(context)?)
}