11use crate :: error:: Result ;
22use crate :: web:: rustdoc:: RustdocPage ;
33use anyhow:: Context ;
4- use rinja :: Template ;
4+ use askama :: Template ;
55use std:: sync:: Arc ;
66use tracing:: trace;
77
@@ -88,12 +88,12 @@ impl TemplateData {
8888}
8989
9090pub mod filters {
91+ use askama:: filters:: Safe ;
9192 use chrono:: { DateTime , Utc } ;
92- use rinja:: filters:: Safe ;
9393 use std:: borrow:: Cow ;
9494
9595 // Copied from `tera`.
96- pub fn escape_html ( input : & str ) -> rinja :: Result < Cow < ' _ , str > > {
96+ pub fn escape_html ( input : & str ) -> askama :: Result < Cow < ' _ , str > > {
9797 if !input. chars ( ) . any ( |c| "&<>\" '/" . contains ( c) ) {
9898 return Ok ( Cow :: Borrowed ( input) ) ;
9999 }
@@ -115,7 +115,7 @@ pub mod filters {
115115 }
116116
117117 // Copied from `tera`.
118- pub fn escape_xml ( input : & str ) -> rinja :: Result < Cow < ' _ , str > > {
118+ pub fn escape_xml ( input : & str ) -> askama :: Result < Cow < ' _ , str > > {
119119 if !input. chars ( ) . any ( |c| "&<>\" '" . contains ( c) ) {
120120 return Ok ( Cow :: Borrowed ( input) ) ;
121121 }
@@ -135,11 +135,11 @@ pub mod filters {
135135
136136 /// Prettily format a timestamp
137137 // TODO: This can be replaced by chrono
138- pub fn timeformat ( value : & DateTime < Utc > ) -> rinja :: Result < String > {
138+ pub fn timeformat ( value : & DateTime < Utc > ) -> askama :: Result < String > {
139139 Ok ( crate :: web:: duration_to_str ( * value) )
140140 }
141141
142- pub fn format_secs ( mut value : f32 ) -> rinja :: Result < String > {
142+ pub fn format_secs ( mut value : f32 ) -> askama :: Result < String > {
143143 const TIMES : & [ & str ] = & [ "seconds" , "minutes" , "hours" ] ;
144144
145145 let mut chosen_time = & TIMES [ 0 ] ;
@@ -167,7 +167,7 @@ pub mod filters {
167167 pub fn dedent < T : std:: fmt:: Display , I : Into < Option < i32 > > > (
168168 value : T ,
169169 levels : I ,
170- ) -> rinja :: Result < String > {
170+ ) -> askama :: Result < String > {
171171 let string = value. to_string ( ) ;
172172
173173 let unindented = if let Some ( levels) = levels. into ( ) {
@@ -200,7 +200,7 @@ pub mod filters {
200200 Ok ( unindented)
201201 }
202202
203- pub fn highlight ( code : impl std:: fmt:: Display , lang : & str ) -> rinja :: Result < Safe < String > > {
203+ pub fn highlight ( code : impl std:: fmt:: Display , lang : & str ) -> askama :: Result < Safe < String > > {
204204 let highlighted_code =
205205 crate :: web:: highlight:: with_lang ( Some ( lang) , & code. to_string ( ) , None ) ;
206206 Ok ( Safe ( format ! (
@@ -209,7 +209,7 @@ pub mod filters {
209209 ) ) )
210210 }
211211
212- pub fn round ( value : & f32 , precision : u32 ) -> rinja :: Result < String > {
212+ pub fn round ( value : & f32 , precision : u32 ) -> askama :: Result < String > {
213213 let multiplier = if precision == 0 {
214214 1.0
215215 } else {
@@ -218,43 +218,43 @@ pub mod filters {
218218 Ok ( ( ( multiplier * * value) . round ( ) / multiplier) . to_string ( ) )
219219 }
220220
221- pub fn split_first < ' a > ( value : & ' a str , pat : & str ) -> rinja :: Result < Option < & ' a str > > {
221+ pub fn split_first < ' a > ( value : & ' a str , pat : & str ) -> askama :: Result < Option < & ' a str > > {
222222 Ok ( value. split ( pat) . next ( ) )
223223 }
224224
225- pub fn json_encode < T : ?Sized + serde:: Serialize > ( value : & T ) -> rinja :: Result < Safe < String > > {
225+ pub fn json_encode < T : ?Sized + serde:: Serialize > ( value : & T ) -> askama :: Result < Safe < String > > {
226226 Ok ( Safe (
227227 serde_json:: to_string ( value) . expect ( "`encode_json` failed" ) ,
228228 ) )
229229 }
230230}
231231
232232pub trait RenderSolid {
233- fn render_solid ( & self , fw : bool , spin : bool , extra : & str ) -> rinja :: filters:: Safe < String > ;
233+ fn render_solid ( & self , fw : bool , spin : bool , extra : & str ) -> askama :: filters:: Safe < String > ;
234234}
235235
236236impl < T : font_awesome_as_a_crate:: Solid > RenderSolid for T {
237- fn render_solid ( & self , fw : bool , spin : bool , extra : & str ) -> rinja :: filters:: Safe < String > {
237+ fn render_solid ( & self , fw : bool , spin : bool , extra : & str ) -> askama :: filters:: Safe < String > {
238238 render ( "fa-solid" , self . icon_name ( ) , fw, spin, extra)
239239 }
240240}
241241
242242pub trait RenderRegular {
243- fn render_regular ( & self , fw : bool , spin : bool , extra : & str ) -> rinja :: filters:: Safe < String > ;
243+ fn render_regular ( & self , fw : bool , spin : bool , extra : & str ) -> askama :: filters:: Safe < String > ;
244244}
245245
246246impl < T : font_awesome_as_a_crate:: Regular > RenderRegular for T {
247- fn render_regular ( & self , fw : bool , spin : bool , extra : & str ) -> rinja :: filters:: Safe < String > {
247+ fn render_regular ( & self , fw : bool , spin : bool , extra : & str ) -> askama :: filters:: Safe < String > {
248248 render ( "fa-regular" , self . icon_name ( ) , fw, spin, extra)
249249 }
250250}
251251
252252pub trait RenderBrands {
253- fn render_brands ( & self , fw : bool , spin : bool , extra : & str ) -> rinja :: filters:: Safe < String > ;
253+ fn render_brands ( & self , fw : bool , spin : bool , extra : & str ) -> askama :: filters:: Safe < String > ;
254254}
255255
256256impl < T : font_awesome_as_a_crate:: Brands > RenderBrands for T {
257- fn render_brands ( & self , fw : bool , spin : bool , extra : & str ) -> rinja :: filters:: Safe < String > {
257+ fn render_brands ( & self , fw : bool , spin : bool , extra : & str ) -> askama :: filters:: Safe < String > {
258258 render ( "fa-brands" , self . icon_name ( ) , fw, spin, extra)
259259 }
260260}
@@ -265,7 +265,7 @@ fn render(
265265 fw : bool ,
266266 spin : bool ,
267267 extra : & str ,
268- ) -> rinja :: filters:: Safe < String > {
268+ ) -> askama :: filters:: Safe < String > {
269269 let mut classes = Vec :: new ( ) ;
270270 if fw {
271271 classes. push ( "fa-fw" ) ;
@@ -281,5 +281,5 @@ fn render(
281281 classes = classes. join( " " ) ,
282282 ) ;
283283
284- rinja :: filters:: Safe ( icon)
284+ askama :: filters:: Safe ( icon)
285285}
0 commit comments