@@ -471,8 +471,46 @@ yaml_encode
471
471
``dumpObjects `` *(optional) *
472
472
**type **: ``boolean `` **default **: ``false ``
473
473
474
- Transforms the input into YAML syntax. See :ref: `components-yaml-dump ` for
475
- more information.
474
+ Transforms the input into YAML syntax.
475
+
476
+ The ``inline `` argument is the level where the generated output switches to inline YAML:
477
+
478
+ .. code-block :: twig
479
+
480
+ {% set array = {
481
+ 'a': {
482
+ 'c': 'e'
483
+ },
484
+ 'b': {
485
+ 'd': 'f'
486
+ }
487
+ } %}
488
+
489
+ {{ array|yaml_encode(inline = 0) }}
490
+ {# output:
491
+ { a: { c: e }, b: { d: f } } #}
492
+
493
+ {{ array|yaml_encode(inline = 1) }}
494
+ {# output:
495
+ a: { c: e }
496
+ b: { d: f } #}
497
+
498
+ The ``dumpObjects `` argument enables the dumping of PHP objects::
499
+
500
+ // ...
501
+ $object = new \stdClass();
502
+ $object->foo = 'bar';
503
+ // ...
504
+
505
+ .. code-block :: twig
506
+
507
+ {{ object|yaml_encode(dumpObjects = false) }}
508
+ {# output: null #}
509
+
510
+ {{ object|yaml_encode(dumpObjects = true) }}
511
+ {# output: !php/object 'O:8:"stdClass":1:{s:5:"foo";s:7:"bar";}' #}
512
+
513
+ See :ref: `components-yaml-dump ` for more information.
476
514
477
515
yaml_dump
478
516
~~~~~~~~~
@@ -491,6 +529,43 @@ yaml_dump
491
529
Does the same as `yaml_encode() <yaml_encode >`_, but includes the type in
492
530
the output.
493
531
532
+ The ``inline `` argument is the level where the generated output switches to inline YAML:
533
+
534
+ .. code-block :: twig
535
+
536
+ {% set array = {
537
+ 'a': {
538
+ 'c': 'e'
539
+ },
540
+ 'b': {
541
+ 'd': 'f'
542
+ }
543
+ } %}
544
+
545
+ {{ array|yaml_dump(inline = 0) }}
546
+ {# output:
547
+ %array% { a: { c: e }, b: { d: f } } #}
548
+
549
+ {{ array|yaml_dump(inline = 1) }}
550
+ {# output:
551
+ %array% a: { c: e }
552
+ b: { d: f } #}
553
+
554
+ The ``dumpObjects `` argument enables the dumping of PHP objects::
555
+
556
+ // ...
557
+ $object = new \stdClass();
558
+ $object->foo = 'bar';
559
+ // ...
560
+
561
+ .. code-block :: twig
562
+
563
+ {{ object|yaml_dump(dumpObjects = false) }}
564
+ {# output: %object% null #}
565
+
566
+ {{ object|yaml_dump(dumpObjects = true) }}
567
+ {# output: %object% !php/object 'O:8:"stdClass":1:{s:3:"foo";s:3:"bar";}' #}
568
+
494
569
abbr_class
495
570
~~~~~~~~~~
496
571
0 commit comments