1use liquid_error::Result;
2use liquid_interpreter::Renderable;
3
4use super::Language;
5use super::TagTokenIter;
6
7pub trait TagReflection {
8 fn tag(&self) -> &'static str;
9
10 fn description(&self) -> &'static str;
11
12 fn example(&self) -> Option<&'static str> {
13 None
14 }
15
16 fn spec(&self) -> Option<&'static str> {
17 None
18 }
19}
20
21pub trait ParseTag: Send + Sync + ParseTagClone + TagReflection {
28 fn parse(&self, arguments: TagTokenIter, options: &Language) -> Result<Box<Renderable>>;
29}
30
31pub trait ParseTagClone {
32 fn clone_box(&self) -> Box<ParseTag>;
33}
34
35impl<T> ParseTagClone for T
36where
37 T: 'static + ParseTag + Clone,
38{
39 fn clone_box(&self) -> Box<ParseTag> {
40 Box::new(self.clone())
41 }
42}
43
44impl Clone for Box<ParseTag> {
45 fn clone(&self) -> Box<ParseTag> {
46 self.clone_box()
47 }
48}
49
50impl<T> From<T> for Box<ParseTag>
51where
52 T: 'static + ParseTag,
53{
54 fn from(filter: T) -> Self {
55 Box::new(filter)
56 }
57}