@@ -527,64 +527,19 @@ and expression_desc cxt ~(level : int) f x : cxt =
527
527
| Call (e , el , {call_transformed_jsx = Some jsx_element } ) -> (
528
528
match el with
529
529
| [
530
- _tag ;
530
+ tag ;
531
531
{
532
532
expression_desc =
533
533
Caml_block (el, _mutable_flag, _, Lambda. Blk_record {fields});
534
534
};
535
- ] -> (
535
+ ] ->
536
536
let fields =
537
537
Ext_list. array_list_filter_map fields el (fun (f , opt ) x ->
538
538
match x.expression_desc with
539
539
| Undefined _ when opt -> None
540
540
| _ -> Some (f, x))
541
541
in
542
- match jsx_element with
543
- | Parsetree. Jsx_fragment {jsx_fragment_children = children } ->
544
- P. string f " <>" ;
545
- (let children =
546
- fields
547
- |> List. find_map (fun (n , e ) ->
548
- if n = " children" then Some e else None )
549
- in
550
- children
551
- |> Option. iter (fun c ->
552
- P. string f " {" ;
553
- let _ = expression ~level: 1 cxt f c in
554
- P. string f " }" ));
555
- P. string f " </>" ;
556
- cxt
557
- | Parsetree. Jsx_unary_element
558
- {jsx_unary_element_tag_name = {txt = Longident. Lident tagName}} ->
559
- Printf. eprintf " Crazy Tag: %s\n " tagName;
560
- P. string f (Format. sprintf " <%s />" tagName);
561
- cxt
562
- | Parsetree. Jsx_container_element
563
- {
564
- jsx_container_element_tag_name_start =
565
- {txt = Longident. Lident tagName};
566
- } ->
567
- P. string f (Format. sprintf " <%s" tagName);
568
- List. iter
569
- (fun (n , x ) ->
570
- P. space f;
571
- P. string f n;
572
- P. string f " =" ;
573
- P. string f " {" ;
574
- let _ = expression ~level: 0 cxt f x in
575
- P. string f " }" )
576
- fields;
577
- P. string f " ></" ;
578
- P. string f tagName;
579
- P. string f " >" ;
580
- cxt
581
- | _ ->
582
- expression_desc cxt ~level f
583
- (Call
584
- ( e,
585
- el,
586
- {call_transformed_jsx = None ; arity = Full ; call_info = Call_ml }
587
- )))
542
+ print_jsx cxt ~level f tag fields
588
543
| _ ->
589
544
expression_desc cxt ~level f
590
545
(Call
@@ -1027,6 +982,74 @@ and expression_desc cxt ~(level : int) f x : cxt =
1027
982
P. string f " ..." ;
1028
983
expression ~level: 13 cxt f e)
1029
984
985
+ (*
986
+ (* match jsx_element with
987
+ | Parsetree.Jsx_fragment {jsx_fragment_children = children} ->
988
+ P.string f "<>";
989
+ (let children =
990
+ fields
991
+ |> List.find_map (fun (n, e) ->
992
+ if n = "children" then Some e else None)
993
+ in
994
+ children
995
+ |> Option.iter (fun c ->
996
+ P.string f "{";
997
+ let _ = expression ~level:1 cxt f c in
998
+ P.string f "}"));
999
+ P.string f "</>";
1000
+ cxt
1001
+ | Parsetree.Jsx_unary_element
1002
+ {jsx_unary_element_tag_name = {txt = Longident.Lident tagName}} ->
1003
+ Printf.eprintf "Crazy Tag: %s\n" tagName;
1004
+ P.string f (Format.sprintf "<%s />" tagName);
1005
+ cxt
1006
+ | Parsetree.Jsx_container_element
1007
+ {
1008
+ jsx_container_element_tag_name_start =
1009
+ {txt = Longident.Lident tagName};
1010
+ } ->
1011
+ P.string f (Format.sprintf "<%s" tagName);
1012
+ List.iter
1013
+ (fun (n, x) ->
1014
+ P.space f;
1015
+ P.string f n;
1016
+ P.string f "=";
1017
+ P.string f "{";
1018
+ let _ = expression ~level:0 cxt f x in
1019
+ P.string f "}")
1020
+ fields;
1021
+ P.string f "></";
1022
+ P.string f tagName;
1023
+ P.string f ">";
1024
+ cxt *)
1025
+ | _ ->
1026
+ expression_desc cxt ~level f
1027
+ (Call
1028
+ ( e,
1029
+ el,
1030
+ {call_transformed_jsx = None; arity = Full; call_info = Call_ml}
1031
+ )))
1032
+ *)
1033
+
1034
+ and print_jsx cxt ~(level : int ) f (tag : J.expression )
1035
+ (fields : (string * J.expression) list ) : cxt =
1036
+ ignore (level, tag, fields);
1037
+ let children_opt =
1038
+ List. find_map (fun (n , e ) -> if n = " children" then Some e else None ) fields
1039
+ in
1040
+ (match children_opt with
1041
+ | None -> P. string f " < />"
1042
+ | Some children ->
1043
+ P. string f " <" ;
1044
+ let _ = expression ~level cxt f tag in
1045
+ P. string f " >" ;
1046
+ let _ = expression ~level cxt f children in
1047
+ P. string f " </" ;
1048
+ let _ = expression ~level cxt f tag in
1049
+ P. string f " >" );
1050
+
1051
+ cxt
1052
+
1030
1053
and property_name_and_value_list cxt f (l : J.property_map ) =
1031
1054
iter_lst cxt f l
1032
1055
(fun cxt f (pn , e ) ->
0 commit comments