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
//! The [`tour`][1] template parser.
//!
//! The [`Parser`] type will only scan for delimiters to split expressions and static contents.
//! [`Parser`] requires a [`Visitor`] implementation which will actually process the inputs.
//!
//! For example:
//!
//! ```html
//! Hello {{ name.to_uppercase() }}
//! ```
//!
//! [`Parser`] will split the input, and call [`Visitor::visit_static`] with `"Hello "`, and
//! [`Visitor::visit_expr`] with `"name.to_uppercase()"`.
//!
//! This separation allows for both compile time and runtime template loading without bringing an
//! entire parser in the binary.
//!
//! The [`tour-macros`][2] contains implementation of [`Visitor`] utilizing the [`syn`][1]
//! crate, which allows rust expression inside template.
//!
//! There is also [`StaticVisitor`] that only collect static content. This implementations is used
//! in runtime template reloading.
//!
//! # Example
//!
//! ```
//! use tour_core::{Parser, StaticVisitor};
//!
//! let source = "Hello {{ name.to_uppercase() }} !";
//!
//! let visitor = Parser::new(source, StaticVisitor::new()).parse().unwrap();
//!
//! assert_eq!(&visitor.statics[..], &["Hello "," !"]);
//! ```
//!
//! [1]: <https://docs.rs/tour>
//! [2]: <https://docs.rs/tour-macros>
//! [3]: <https://docs.rs/syn>
pub use Delimiter;
pub use ;
pub use Parser;
pub use ;