@@ -9,7 +9,6 @@ use rayon::prelude::*;
9
9
use sass_rs:: { Options , compile_file} ;
10
10
use serde:: Serialize ;
11
11
use serde_json:: { Value , json} ;
12
- use std:: collections:: HashMap ;
13
12
use std:: fs:: { self , File } ;
14
13
use std:: io:: { self , Write } ;
15
14
use std:: path:: { Path , PathBuf } ;
@@ -33,53 +32,12 @@ struct ReleasePost {
33
32
url : String ,
34
33
}
35
34
36
- fn month_name ( month_num : & Value , _args : & HashMap < String , Value > ) -> tera:: Result < Value > {
37
- let month_num = month_num
38
- . as_u64 ( )
39
- . expect ( "month_num should be an unsigned integer" ) ;
40
- let name = match month_num {
41
- 1 => "Jan." ,
42
- 2 => "Feb." ,
43
- 3 => "Mar." ,
44
- 4 => "Apr." ,
45
- 5 => "May" ,
46
- 6 => "June" ,
47
- 7 => "July" ,
48
- 8 => "Aug." ,
49
- 9 => "Sept." ,
50
- 10 => "Oct." ,
51
- 11 => "Nov." ,
52
- 12 => "Dec." ,
53
- _ => panic ! ( "invalid month! ({month_num})" ) ,
54
- } ;
55
- Ok ( name. into ( ) )
56
- }
57
-
58
- // Tera and Handlebars escape HTML differently by default.
59
- // Tera: &<>"'/
60
- // Handlebars: &<>"'`=
61
- // To make the transition testable, this function escapes just like Handlebars.
62
- fn escape_hbs ( input : & Value , _args : & HashMap < String , Value > ) -> tera:: Result < Value > {
63
- let input = input. as_str ( ) . expect ( "input should be a string" ) ;
64
- Ok ( input
65
- . replace ( "&" , "&" )
66
- . replace ( "<" , "<" )
67
- . replace ( ">" , ">" )
68
- . replace ( "\" " , """ )
69
- . replace ( "'" , "'" )
70
- . replace ( "`" , "`" )
71
- . replace ( "=" , "=" )
72
- . into ( ) )
73
- }
74
-
75
35
impl Generator {
76
36
fn new (
77
37
out_directory : impl AsRef < Path > ,
78
38
posts_directory : impl AsRef < Path > ,
79
39
) -> eyre:: Result < Self > {
80
40
let mut tera = Tera :: new ( "templates/*" ) ?;
81
- tera. register_filter ( "month_name" , month_name) ;
82
- tera. register_filter ( "escape_hbs" , escape_hbs) ;
83
41
tera. autoescape_on ( vec ! [ ] ) ; // disable auto-escape for .html templates
84
42
Ok ( Generator {
85
43
tera,
0 commit comments