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