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
201
202
203
204
205
206
207
208
209
extern crate proc_macro;
use TokenStream;
use crate;
use ;
use parse_macro_input;
use Component;
use Uuid;
use crateI18n;
/// Turn your template into a usable string
///
/// # Examples
/// ## A for loop
/// ```rust,no_run
///use tidos_macro::view;
///let names = vec!["Bob", "Alice"];
///
///view! {
/// {#for name in names}
/// <p>{format!("Hello {}!", name)}</p>
/// {/for}
///}
/// ```
/// ## A match statement
/// ```rust,no_run
/// enum Pet {
/// Fish,
/// Dog,
/// Cat,
/// Other { name: String }
/// }
///
/// use tidos_macro::view;
/// use Pet::*;
///
/// let my_pet = Dog;
///
/// view! {
/// {#match my_pet}
/// {:case Fish}
/// <p>Blub!</p>
/// {:case Dog}
/// <p>Who's a good boy!</p>
/// {:case Cat}
/// <p>Give all mortal possessions to cat!</p>
/// {:case _}
/// <p>Is it a snake or a spider?</p>
/// {/match}
/// }
/// ```
///
/// ## If/else statements
/// ```rust,no_run
///use tidos_macro::view;
///let age = 18;
///
///let is_american = false;
///
///view! {
/// {#if age >= 18 && !is_american}
/// <p>User is allowed to drink.</p>
/// {:else if age >= 21 && is_american}
/// <p>User is allowed to drink.</p>
/// {:else if age >= 18 && age < 21 && is_american}
/// <p>User is probably designated driver.</p>
/// {:else}
/// <p>User is not allowed to drink.</p>
/// {/if}
///}
/// ```
/// Similar to the view, however it will also render the templates into a page context.
///
/// # Example
/// ```rust,no_run
/// pub fn getting_started() -> Page {
/// let x: isize = Default::default();
///
/// page! {
/// <main>
/// <h1>Getting started</h1>
/// <p>Cargo add</p>
/// <p>{x.to_string()}</p>
/// </main>
/// }
/// }
/// ```
/// Adds body contents to the head of the page
///
/// # example
/// ```rust,no_run
///use tidos_macro::{head, view};
///
///pub struct Title {
/// pub title: String,
///}
///
///impl Component for Title {
/// fn to_render(&self, page: &mut Page) -> String {
/// head! {
/// <title>{&self.title}</title>
/// }
/// String::new()
/// }
///}
/// ```
/// CSS file to include in the head of the body.
/// Macro returns a CSS class you can use in your view template
///
/// # Example
/// ```rust,no_run
/// use tidos_macro::{scoped_css, view};
///
/// pub struct DocsGrid {
/// pub content: String
/// }
///
/// impl Component for DocsGrid {
/// fn to_render(&self, page: &mut Page) -> String {
/// let css = scoped_css!("./mod.css");
///
///
/// view! {
/// <div class={css}>
/// <div>
/// <DocsSidenav />
/// <main>
/// @html{&self.content}
/// </main>
/// <DocsOnThisPage />
/// </div>
/// </div>
///
/// }
/// }
/// }
/// ```
///