@@ -887,34 +887,36 @@ def save(self, filename: Union[IO[bytes], str, PathLike], *args, **kwargs) -> No
887
887
self .is_saved = True
888
888
889
889
def get_undeclared_template_variables (
890
- self , jinja_env : Optional [Environment ] = None , context : Optional [Dict [str , Any ]] = None
890
+ self ,
891
+ jinja_env : Optional [Environment ] = None ,
892
+ context : Optional [Dict [str , Any ]] = None ,
891
893
) -> Set [str ]:
892
894
# Create a temporary document to analyze the template without affecting the current state
893
895
temp_doc = Document (self .template_file )
894
-
896
+
895
897
# Get XML from the temporary document
896
898
xml = self .xml_to_string (temp_doc ._element .body )
897
899
xml = self .patch_xml (xml )
898
-
900
+
899
901
# Add headers and footers
900
902
for uri in [self .HEADER_URI , self .FOOTER_URI ]:
901
903
for relKey , val in temp_doc ._part .rels .items ():
902
904
if (val .reltype == uri ) and (val .target_part .blob ):
903
905
_xml = self .xml_to_string (parse_xml (val .target_part .blob ))
904
906
xml += self .patch_xml (_xml )
905
-
907
+
906
908
if jinja_env :
907
909
env = jinja_env
908
910
else :
909
911
env = Environment ()
910
-
912
+
911
913
parse_content = env .parse (xml )
912
914
all_variables = meta .find_undeclared_variables (parse_content )
913
-
915
+
914
916
# If context is provided, return only variables that are not in the context
915
917
if context is not None :
916
918
provided_variables = set (context .keys ())
917
919
return all_variables - provided_variables
918
-
920
+
919
921
# If no context provided, return all variables (original behavior)
920
- return all_variables
922
+ return all_variables
0 commit comments