@@ -699,23 +699,41 @@ impl MultiTemplate {
699
699
return Err ( "Internal error: template index out of bounds" . to_string ( ) ) ;
700
700
}
701
701
702
- // Join multiple inputs with the corresponding separator
702
+ // Process each input individually, then join the results
703
703
let section_inputs = inputs[ template_index] ;
704
704
let separator = separators[ template_index] ;
705
- let input = match section_inputs. len ( ) {
705
+ let output = match section_inputs. len ( ) {
706
706
0 => String :: new ( ) ,
707
- 1 => section_inputs[ 0 ] . to_string ( ) ,
708
- _ => section_inputs. join ( separator) ,
707
+ 1 => {
708
+ let mut input_hasher = std:: collections:: hash_map:: DefaultHasher :: new ( ) ;
709
+ std:: hash:: Hash :: hash ( & section_inputs[ 0 ] , & mut input_hasher) ;
710
+ let input_hash = input_hasher. finish ( ) ;
711
+
712
+ self . apply_template_section (
713
+ section_inputs[ 0 ] ,
714
+ ops,
715
+ input_hash,
716
+ & mut cache,
717
+ & None , // No debug tracing for structured processing
718
+ ) ?
719
+ }
720
+ _ => {
721
+ let mut results = Vec :: new ( ) ;
722
+ for input in section_inputs {
723
+ let mut input_hasher =
724
+ std:: collections:: hash_map:: DefaultHasher :: new ( ) ;
725
+ std:: hash:: Hash :: hash ( & input, & mut input_hasher) ;
726
+ let input_hash = input_hasher. finish ( ) ;
727
+
728
+ let result = self . apply_template_section (
729
+ input, ops, input_hash, & mut cache,
730
+ & None , // No debug tracing for structured processing
731
+ ) ?;
732
+ results. push ( result) ;
733
+ }
734
+ results. join ( separator)
735
+ }
709
736
} ;
710
-
711
- let mut input_hasher = std:: collections:: hash_map:: DefaultHasher :: new ( ) ;
712
- std:: hash:: Hash :: hash ( & input, & mut input_hasher) ;
713
- let input_hash = input_hasher. finish ( ) ;
714
-
715
- let output = self . apply_template_section (
716
- & input, ops, input_hash, & mut cache,
717
- & None , // No debug tracing for structured processing
718
- ) ?;
719
737
result. push_str ( & output) ;
720
738
template_index += 1 ;
721
739
}
0 commit comments