File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
user_guide_src/source/outgoing Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -109,15 +109,20 @@ public function testDefault(): void
109
109
$ parser = new Parser ($ this ->config , $ this ->viewsDir , $ this ->loader );
110
110
111
111
$ data = [
112
- 'value1 ' => null ,
113
- 'value2 ' => 0 ,
114
- 'value3 ' => 'test ' ,
112
+ 'value1 ' => '' ,
113
+ 'value2 ' => null ,
114
+ 'value3 ' => 0 ,
115
+ 'value4 ' => 'test ' ,
115
116
];
116
117
117
- $ template = '{ value1|default(foo) } { value2|default(bar) } { value3|default(baz) } ' ;
118
+ $ template = '{ value1|default(foo) } { value2|default(bar) } { value3|default(baz) } '
119
+ . ' { value4|default(boo) } { undef|default(far) } ' ;
118
120
119
121
$ parser ->setData ($ data );
120
- $ this ->assertSame ('foo bar test ' , $ parser ->renderString ($ template ));
122
+ $ this ->assertSame (
123
+ 'foo bar baz test { undef|default(far) } ' ,
124
+ $ parser ->renderString ($ template )
125
+ );
121
126
}
122
127
123
128
public function testEsc (): void
Original file line number Diff line number Diff line change @@ -371,8 +371,7 @@ date format (Y-m-d) A PHP **date**-compatible formatting string.
371
371
date_modify value to add A **strtotime ** compatible string to modify the date, { v|date_modify(+1 day) }
372
372
/ subtract like ``+5 day `` or ``-1 week ``.
373
373
374
- default default value Displays the default value if the variable is empty or { v|default(just in case) }
375
- undefined.
374
+ default default value Displays the default value if the variable is `empty() `_. { v|default(just in case) }
376
375
377
376
esc html, attr, Specifies the context to escape the data. { v|esc(attr) }
378
377
css, js
@@ -419,6 +418,8 @@ title Displays a "title case" version of the string
419
418
upper Displays the string in all uppercase. { v|upper }
420
419
================ ================= =========================================================== ======================================
421
420
421
+ .. _empty(): https://www.php.net/manual/en/function.empty.php
422
+
422
423
See `PHP's NumberFormatter <https://www.php.net/manual/en/numberformatter.create.php >`_ for details relevant to the
423
424
"local_number" filter.
424
425
You can’t perform that action at this time.
0 commit comments