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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#[macro_export]
macro_rules! html {
($($inner:tt)*) => {{
let f = |tmpl: &mut $crate::TemplateBuilder| -> () {
__append_html!(tmpl, $($inner)*);
};
$crate::__new_renderer(stringify!($($inner)*).len(), f)
}}
}
#[macro_export]
macro_rules! box_html {
($($inner:tt)*) => {{
let f = move |tmpl: &mut $crate::TemplateBuilder| -> () {
__append_html!(tmpl, $($inner)*);
};
$crate::__new_boxed_renderer(stringify!($($inner)*).len(), f)
}}
}
#[doc(hidden)]
#[macro_export]
macro_rules! stringify_compressed {
($($tok:tt)*) => {
concat!($(stringify!($tok)),*)
};
}
#[macro_export]
macro_rules! raw {
($e:expr) => { $crate::Raw::new($e) }
}
#[macro_export]
#[doc(hidden)]
macro_rules! __horrorshow_block_identity {
($b:block) => { $b };
}
#[doc(hidden)]
#[macro_export]
macro_rules! __append_html {
($tmpl:ident, : {$($code:tt)*} $($next:tt)*) => {{
$crate::RenderOnce::render_once({$($code)*}, $tmpl);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, : $code:expr; $($next:tt)* ) => {{
$crate::RenderOnce::render_once($code, $tmpl);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, : $code:expr ) => {{
$crate::RenderOnce::render_once($code, $tmpl);
}};
($tmpl:ident, |$var:ident| {$($code:tt)*} $($next:tt)*) => {{
(|$var: &mut $crate::TemplateBuilder| {
__horrorshow_block_identity!({$($code)*})
})($tmpl);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, |mut $var:ident| {$($code:tt)*} $($next:tt)*) => {{
(|mut $var: &mut $crate::TemplateBuilder| {
__horrorshow_block_identity!({$($code)*})
})($tmpl);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, |$var:ident| $code:stmt; $($next:tt)* ) => {{
(|$var: &mut $crate::TemplateBuilder| {
$code;
})($tmpl);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, |mut $var:ident| $code:stmt; $($next:tt)* ) => {{
(|mut $var: &mut $crate::TemplateBuilder| {
$code;
})($tmpl);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, |$var:ident| $code:stmt ) => {{
(|$var: &mut $crate::TemplateBuilder| {
$code;
})($tmpl);
}};
($tmpl:ident, |mut $var:ident| $code:stmt ) => {{
(|mut $var: &mut $crate::TemplateBuilder| {
$code;
})($tmpl);
}};
($tmpl:ident, #{$($tok:tt)+} $($next:tt)*) => {{
write!($tmpl, $($tok)+);
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, $tag:ident($($($($attr:ident)-+):+ = $value:expr),+) { $($children:tt)* } $($next:tt)* ) => {{
$tmpl.write_raw(concat!("<", stringify!($tag)));
$(
$tmpl.write_raw(concat!(" ", stringify_compressed!($($($attr)-+):+), "=\""));
write!($tmpl, "{}", $value);
$tmpl.write_raw("\"");
)+
$tmpl.write_raw(">");
__append_html!($tmpl, $($children)*);
$tmpl.write_raw(concat!("</", stringify!($tag), ">"));
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, $tag:ident($($attr:tt)+) : $e:expr; $($next:tt)* ) => {{
__append_html!($tmpl, $tag($($attr)+) { : $e; } $($next)* );
}};
($tmpl:ident, $tag:ident($($attr:tt)+) : {$($code:tt)*} $($next)* ) => {{
__append_html!($tmpl, $tag($($attr)+) { : {$($code)*} } $($next)* );
}};
($tmpl:ident, $tag:ident($($($($attr:ident)-+):+ = $value:expr),+); $($next:tt)*) => {{
$tmpl.write_raw(concat!("<", stringify!($tag)));
$(
$tmpl.write_raw(concat!(" ", stringify_compressed!($($($attr)-+):+), "=\""));
write!($tmpl, "{}", $value);
$tmpl.write_raw("\"");
)+
$tmpl.write_raw(" />");
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, $tag:ident($($($($attr:ident)-+):+ = $value:expr),+)) => {{
$tmpl.write_raw(concat!("<", stringify!($tag)));
$(
$tmpl.write_raw(concat!(" ", stringify_compressed!($($($attr)-+):+), "=\""));
write!($tmpl, "{}", $value);
$tmpl.write_raw("\"");
)+
$tmpl.write_raw(" />");
}};
($tmpl:ident, $tag:ident { $($children:tt)* } $($next:tt)* ) => {{
$tmpl.write_raw(concat!("<", stringify!($tag), ">"));
__append_html!($tmpl, $($children)*);
$tmpl.write_raw(concat!("</", stringify!($tag), ">"));
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, $tag:ident : $e:expr; $($next:tt)* ) => {{
__append_html!($tmpl, $tag { : $e; } $($next)* );
}};
($tmpl:ident, $tag:ident : {$($code:tt)*} $($next:tt)* ) => {{
__append_html!($tmpl, $tag { : {$($code)*} } $($next)* );
}};
($tmpl:ident, $tag:ident; $($next:tt)*) => {{
$tmpl.write_raw(concat!("<", stringify!($tag), " />"));
__append_html!($tmpl, $($next)*);
}};
($tmpl:ident, $tag:ident : $e:expr) => {{
__append_html!($tmpl, $tag { : $e; });
}};
($tmpl:ident, $tag:ident) => {{
$tmpl.write_raw(concat!("<", stringify!($tag), "/>"));
}};
($tmpl:ident,) => {};
}