@@ -26,8 +26,7 @@ use crate::parse::{
2626} ;
2727use crate :: path:: construct_relative_path;
2828use crate :: template:: django_rusty_templates:: {
29- NoReverseMatch , Template , TemplateDoesNotExist , TemplateSyntaxError , WithSourceCode ,
30- get_template,
29+ NoReverseMatch , Template , TemplateDoesNotExist , TemplateSyntaxError , get_template,
3130} ;
3231use crate :: types:: Variable ;
3332use crate :: utils:: PyResultMethods ;
@@ -1102,39 +1101,6 @@ impl Extends {
11021101 }
11031102 }
11041103
1105- fn get_template_from_string < ' t , ' py > (
1106- & self ,
1107- content : & Bound < ' py , PyString > ,
1108- template : TemplateString < ' t > ,
1109- context : & mut Context ,
1110- ) -> Result < Template , PyErr > {
1111- let py = content. py ( ) ;
1112- let template_path = content
1113- . extract ( )
1114- . expect ( "PyString should be compatible with Cow<str>" ) ;
1115- let origin_name = match & self . origin {
1116- Some ( origin) => origin. template_name . as_deref ( ) ,
1117- None => None ,
1118- } ;
1119- let relative_path =
1120- construct_relative_path ( template_path, origin_name, template_at ( & self . template_name ) ) ;
1121- let template_path =
1122- match relative_path {
1123- Err ( error) => {
1124- return Err ( TemplateDoesNotExist :: with_source_code (
1125- error. into ( ) ,
1126- template. to_string ( ) ,
1127- ) ) ;
1128- }
1129- Ok ( Some ( _) ) => {
1130- return Err ( TemplateDoesNotExist :: new_err ( ( template_path. to_string ( ) , ) )
1131- . annotate ( py, template_at ( & self . template_name ) , "here" , template) ) ;
1132- }
1133- Ok ( None ) => template_path. to_string ( ) ,
1134- } ;
1135- self . load_template ( py, template_path, template, context)
1136- }
1137-
11381104 fn get_template < ' t , ' py > (
11391105 & self ,
11401106 template_name : Content < ' t , ' py > ,
@@ -1150,13 +1116,19 @@ impl Extends {
11501116 if let Ok ( parent) = content. extract :: < Template > ( ) {
11511117 Ok ( parent)
11521118 } else if let Ok ( content) = content. cast :: < PyString > ( ) {
1153- self . get_template_from_string ( content, template, context)
1119+ let template_path = content
1120+ . extract ( )
1121+ . expect ( "PyString should be compatible with Cow<str>" ) ;
1122+ self . load_template ( py, template_path, template, context)
11541123 } else {
11551124 let promise = PROMISE . import ( py, "django.utils.functional" , "Promise" ) ?;
11561125 let path_like = PATH_LIKE . import ( py, "os" , "PathLike" ) ?;
11571126 if content. is_instance ( promise) ? || content. is_instance ( path_like) ? {
11581127 let content = content. str ( ) ?;
1159- self . get_template_from_string ( & content, template, context)
1128+ let template_path = content
1129+ . extract ( )
1130+ . expect ( "PyString should be compatible with Cow<str>" ) ;
1131+ self . load_template ( py, template_path, template, context)
11601132 } else {
11611133 return Err ( invalid_template_name (
11621134 py,
0 commit comments