@@ -483,8 +483,45 @@ yaml_encode
483
483
``dumpObjects `` *(optional) *
484
484
**type **: ``boolean `` **default **: ``false ``
485
485
486
- Transforms the input into YAML syntax. See :ref: `components-yaml-dump ` for
487
- more information.
486
+ Transforms the input into YAML syntax.
487
+
488
+ The ``inline `` argument is the level where you switch to inline YAML:
489
+
490
+ .. code-block :: twig
491
+
492
+ {% set array = {
493
+ 'a': {
494
+ 'c': 'e'
495
+ },
496
+ 'b': {
497
+ 'd': 'f'
498
+ }
499
+ } %}
500
+
501
+ {{ array|yaml_encode(0) }}
502
+ {# output: { a: { c: e }, b: { d: f } } #}
503
+
504
+ {{ array|yaml_encode(1) }}
505
+ {# output: a: { c: e } b: { d: f } #}
506
+
507
+ The ``dumpObjects `` argument is used to dump objects:
508
+
509
+ .. code-block :: php
510
+
511
+ // ...
512
+ $object = new \stdClass();
513
+ $object->foo = 'bar';
514
+ // ...
515
+
516
+ .. code-block :: twig
517
+
518
+ {{ object|yaml_encode(0, false) }}
519
+ {# output: null #}
520
+
521
+ {{ object|yaml_encode(0, true) }}
522
+ {# output: !php/object 'O:8:"stdClass":1:{s:5:"foo";s:7:"bar";}' #}
523
+
524
+ See :ref: `components-yaml-dump ` for more information.
488
525
489
526
yaml_dump
490
527
~~~~~~~~~
@@ -503,6 +540,42 @@ yaml_dump
503
540
Does the same as `yaml_encode() <yaml_encode >`_, but includes the type in
504
541
the output.
505
542
543
+ The ``inline `` argument is the level where you switch to inline YAML:
544
+
545
+ .. code-block :: twig
546
+
547
+ {% set array = {
548
+ 'a': {
549
+ 'c': 'e'
550
+ },
551
+ 'b': {
552
+ 'd': 'f'
553
+ }
554
+ } %}
555
+
556
+ {{ array|yaml_dump(0) }}
557
+ {# output: %array% { a: { c: e }, b: { d: f } } #}
558
+
559
+ {{ array|yaml_dump(1) }}
560
+ {# output: %array% a: { c: e } b: { d: f } #}
561
+
562
+ The ``dumpObjects `` argument is used to dump objects:
563
+
564
+ .. code-block :: php
565
+
566
+ // ...
567
+ $object = new \stdClass();
568
+ $object->foo = 'bar';
569
+ // ...
570
+
571
+ .. code-block :: twig
572
+
573
+ {{ object|yaml_dump(0, false) }}
574
+ {# output: %object% null #}
575
+
576
+ {{ object|yaml_dump(0, true) }}
577
+ {# output: %object% !php/object 'O:8:"stdClass":1:{s:3:"foo";s:3:"bar";}' #}
578
+
506
579
abbr_class
507
580
~~~~~~~~~~
508
581
0 commit comments