@@ -88,12 +88,13 @@ impl TemplateData {
8888}
8989
9090pub mod filters {
91+ use askama:: Values ;
9192 use askama:: filters:: Safe ;
9293 use chrono:: { DateTime , Utc } ;
9394 use std:: borrow:: Cow ;
9495
9596 // Copied from `tera`.
96- pub fn escape_html ( input : & str ) -> askama:: Result < Cow < ' _ , str > > {
97+ pub fn escape_html < ' a > ( input : & ' a str , _ : & dyn Values ) -> askama:: Result < Cow < ' a , str > > {
9798 if !input. chars ( ) . any ( |c| "&<>\" '/" . contains ( c) ) {
9899 return Ok ( Cow :: Borrowed ( input) ) ;
99100 }
@@ -115,7 +116,7 @@ pub mod filters {
115116 }
116117
117118 // Copied from `tera`.
118- pub fn escape_xml ( input : & str ) -> askama:: Result < Cow < ' _ , str > > {
119+ pub fn escape_xml < ' a > ( input : & ' a str , _ : & dyn Values ) -> askama:: Result < Cow < ' a , str > > {
119120 if !input. chars ( ) . any ( |c| "&<>\" '" . contains ( c) ) {
120121 return Ok ( Cow :: Borrowed ( input) ) ;
121122 }
@@ -135,11 +136,11 @@ pub mod filters {
135136
136137 /// Prettily format a timestamp
137138 // TODO: This can be replaced by chrono
138- pub fn timeformat ( value : & DateTime < Utc > ) -> askama:: Result < String > {
139+ pub fn timeformat ( value : & DateTime < Utc > , _ : & dyn Values ) -> askama:: Result < String > {
139140 Ok ( crate :: web:: duration_to_str ( * value) )
140141 }
141142
142- pub fn format_secs ( mut value : f32 ) -> askama:: Result < String > {
143+ pub fn format_secs ( mut value : f32 , _ : & dyn Values ) -> askama:: Result < String > {
143144 const TIMES : & [ & str ] = & [ "seconds" , "minutes" , "hours" ] ;
144145
145146 let mut chosen_time = & TIMES [ 0 ] ;
@@ -166,6 +167,7 @@ pub mod filters {
166167 #[ allow( clippy:: unnecessary_wraps) ]
167168 pub fn dedent < T : std:: fmt:: Display , I : Into < Option < i32 > > > (
168169 value : T ,
170+ _: & dyn Values ,
169171 levels : I ,
170172 ) -> askama:: Result < String > {
171173 let string = value. to_string ( ) ;
@@ -200,7 +202,11 @@ pub mod filters {
200202 Ok ( unindented)
201203 }
202204
203- pub fn highlight ( code : impl std:: fmt:: Display , lang : & str ) -> askama:: Result < Safe < String > > {
205+ pub fn highlight (
206+ code : impl std:: fmt:: Display ,
207+ _: & dyn Values ,
208+ lang : & str ,
209+ ) -> askama:: Result < Safe < String > > {
204210 let highlighted_code =
205211 crate :: web:: highlight:: with_lang ( Some ( lang) , & code. to_string ( ) , None ) ;
206212 Ok ( Safe ( format ! (
@@ -209,7 +215,7 @@ pub mod filters {
209215 ) ) )
210216 }
211217
212- pub fn round ( value : & f32 , precision : u32 ) -> askama:: Result < String > {
218+ pub fn round ( value : & f32 , _ : & dyn Values , precision : u32 ) -> askama:: Result < String > {
213219 let multiplier = if precision == 0 {
214220 1.0
215221 } else {
@@ -218,11 +224,18 @@ pub mod filters {
218224 Ok ( ( ( multiplier * * value) . round ( ) / multiplier) . to_string ( ) )
219225 }
220226
221- pub fn split_first < ' a > ( value : & ' a str , pat : & str ) -> askama:: Result < Option < & ' a str > > {
227+ pub fn split_first < ' a > (
228+ value : & ' a str ,
229+ _: & dyn Values ,
230+ pat : & str ,
231+ ) -> askama:: Result < Option < & ' a str > > {
222232 Ok ( value. split ( pat) . next ( ) )
223233 }
224234
225- pub fn json_encode < T : ?Sized + serde:: Serialize > ( value : & T ) -> askama:: Result < Safe < String > > {
235+ pub fn json_encode < T : ?Sized + serde:: Serialize > (
236+ value : & T ,
237+ _: & dyn Values ,
238+ ) -> askama:: Result < Safe < String > > {
226239 Ok ( Safe (
227240 serde_json:: to_string ( value) . expect ( "`encode_json` failed" ) ,
228241 ) )
0 commit comments