@@ -142,11 +142,13 @@ pub mod django_rusty_templates {
142142 py : Python < ' _ > ,
143143 template_loaders : Bound < ' _ , PyIterator > ,
144144 encoding : & ' static Encoding ,
145+ dirs : & Vec < PathBuf > ,
145146 ) -> PyResult < Vec < Loader > > {
146147 template_loaders
147148 . map ( |template_loader| {
148- template_loader
149- . and_then ( |template_loader| find_template_loader ( py, template_loader, encoding) )
149+ template_loader. and_then ( |template_loader| {
150+ find_template_loader ( py, template_loader, encoding, dirs)
151+ } )
150152 } )
151153 . collect ( )
152154 }
@@ -155,9 +157,10 @@ pub mod django_rusty_templates {
155157 py : Python < ' _ > ,
156158 loader : Bound < ' _ , PyAny > ,
157159 encoding : & ' static Encoding ,
160+ dirs : & Vec < PathBuf > ,
158161 ) -> PyResult < Loader > {
159162 if let Ok ( loader_str) = loader. extract :: < String > ( ) {
160- return map_loader ( py, & loader_str, None , encoding) ;
163+ return map_loader ( py, & loader_str, None , encoding, dirs ) ;
161164 }
162165
163166 let ( loader_path, args) = unpack ( & loader) . map_err ( |e| {
@@ -167,14 +170,15 @@ pub mod django_rusty_templates {
167170 ) )
168171 } ) ?;
169172
170- map_loader ( py, & loader_path, Some ( args) , encoding)
173+ map_loader ( py, & loader_path, Some ( args) , encoding, dirs )
171174 }
172175
173176 fn map_loader (
174177 py : Python < ' _ > ,
175178 loader_path : & str ,
176179 args : Option < Bound < ' _ , PyAny > > ,
177180 encoding : & ' static Encoding ,
181+ dirs : & Vec < PathBuf > ,
178182 ) -> PyResult < Loader > {
179183 match loader_path {
180184 "django.template.loaders.filesystem.Loader" => {
@@ -185,7 +189,7 @@ pub mod django_rusty_templates {
185189 . collect :: < PyResult < Vec < _ > > > ( )
186190 } )
187191 . transpose ( ) ?
188- . unwrap_or_default ( ) ;
192+ . unwrap_or ( dirs . clone ( ) ) ;
189193
190194 Ok ( Loader :: FileSystem ( FileSystemLoader :: new ( paths, encoding) ) )
191195 }
@@ -208,7 +212,7 @@ pub mod django_rusty_templates {
208212 )
209213 } ) ?
210214 . try_iter ( ) ?
211- . map ( |inner_loader| find_template_loader ( py, inner_loader?, encoding) )
215+ . map ( |inner_loader| find_template_loader ( py, inner_loader?, encoding, dirs ) )
212216 . collect :: < PyResult < Vec < _ > > > ( ) ?;
213217
214218 Ok ( Loader :: Cached ( CachedLoader :: new ( nested_loaders) ) )
@@ -356,7 +360,7 @@ pub mod django_rusty_templates {
356360 ) ;
357361 return Err ( err) ;
358362 }
359- Some ( loaders) => get_template_loaders ( py, loaders. try_iter ( ) ?, encoding) ?,
363+ Some ( loaders) => get_template_loaders ( py, loaders. try_iter ( ) ?, encoding, & dirs ) ?,
360364 None => {
361365 let filesystem_loader =
362366 Loader :: FileSystem ( FileSystemLoader :: new ( dirs. clone ( ) , encoding) ) ;
0 commit comments