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