@@ -9,22 +9,22 @@ use std::rc::Rc;
9
9
/// `Arc` and `Rc` versions.
10
10
macro_rules! get_template_for_path {
11
11
( $raw_path: expr, $render_cfg: expr, $templates: expr) => { {
12
- let mut path = $raw_path;
13
- // If the path is empty, we're looking for the special `index` page
14
- if path. is_empty( ) {
15
- path = "index" ;
16
- }
12
+ let path = $raw_path;
13
+ // // If the path is empty, we're looking for the special `index` page
14
+ // if path.is_empty() {
15
+ // path = "index";
16
+ // }
17
17
18
18
let mut was_incremental_match = false ;
19
19
// Match the path to one of the templates
20
- let mut template_name = String :: new ( ) ;
20
+ let mut template_name = None ;
21
21
// We'll try a direct match first
22
22
if let Some ( template_root_path) = $render_cfg. get( path) {
23
- template_name = template_root_path. to_string( ) ;
23
+ template_name = Some ( template_root_path. to_string( ) ) ;
24
24
}
25
25
// Next, an ISR match (more complex), which we only want to run if we didn't get
26
26
// an exact match above
27
- if template_name. is_empty ( ) {
27
+ if template_name. is_none ( ) {
28
28
// We progressively look for more and more specificity of the path, adding each
29
29
// segment That way, we're searching forwards rather than backwards,
30
30
// which is more efficient
@@ -36,20 +36,20 @@ macro_rules! get_template_for_path {
36
36
// If we find something, keep going until we don't (maximize specificity)
37
37
if let Some ( template_root_path) = $render_cfg. get( & path_to_try) {
38
38
was_incremental_match = true ;
39
- template_name = template_root_path. to_string( ) ;
39
+ template_name = Some ( template_root_path. to_string( ) ) ;
40
40
} else {
41
41
break ;
42
42
}
43
43
}
44
44
}
45
45
// If we still have nothing, then the page doesn't exist
46
- if template_name. is_empty ( ) {
46
+ if template_name. is_none ( ) {
47
47
return ( None , was_incremental_match) ;
48
48
}
49
49
50
50
// Return the necessary info for the caller to get the template in a form it
51
51
// wants (might be an `Rc` of a reference)
52
- ( template_name, was_incremental_match)
52
+ ( template_name. unwrap ( ) , was_incremental_match)
53
53
} } ;
54
54
}
55
55
0 commit comments