--TEST-- "default" filter --TEMPLATE-- Variable: {{ definedVar |default('default') is same as('default') ? 'ko' : 'ok' }} {{ zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }} {{ emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }} {{ nullVar |default('default') is same as('default') ? 'ok' : 'ko' }} {{ undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }} Array access: {{ nested.definedVar |default('default') is same as('default') ? 'ko' : 'ok' }} {{ nested['definedVar'] |default('default') is same as('default') ? 'ko' : 'ok' }} {{ nested.zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }} {{ nested.emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }} {{ nested.nullVar |default('default') is same as('default') ? 'ok' : 'ko' }} {{ nested.undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }} {{ nested['undefinedVar'] |default('default') is same as('default') ? 'ok' : 'ko' }} {{ undefined['undefined'] |default('default') is same as('default') ? 'ok' : 'ko' }} {{ undefinedVar.foo |default('default') is same as('default') ? 'ok' : 'ko' }} Plain values: {{ 'defined' |default('default') is same as('default') ? 'ko' : 'ok' }} {{ 0 |default('default') is same as('default') ? 'ko' : 'ok' }} {{ '' |default('default') is same as('default') ? 'ok' : 'ko' }} {{ null |default('default') is same as('default') ? 'ok' : 'ko' }} Precedence: {{ 'o' ~ nullVar |default('k') }} {{ 'o' ~ nested.nullVar |default('k') }} Object methods: {{ object.foo |default('default') is same as('default') ? 'ko' : 'ok' }} {{ object.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }} {{ object.getFoo() |default('default') is same as('default') ? 'ko' : 'ok' }} {{ object.getFoo('a') |default('default') is same as('default') ? 'ko' : 'ok' }} {{ object.undefinedMethod() |default('default') is same as('default') ? 'ok' : 'ko' }} {{ object.undefinedMethod('a') |default('default') is same as('default') ? 'ok' : 'ko' }} Deep nested: {{ nested.undefinedVar.foo.bar |default('default') is same as('default') ? 'ok' : 'ko' }} {{ nested.definedArray.0 |default('default') is same as('default') ? 'ko' : 'ok' }} {{ nested['definedArray'][0] |default('default') is same as('default') ? 'ko' : 'ok' }} {{ nested['undefinedVar'][0] |default('default') is same as('default') ? 'ok' : 'ko' }} {{ undefined['undefined'][0] |default('default') is same as('default') ? 'ok' : 'ko' }} {{ object.self.foo |default('default') is same as('default') ? 'ko' : 'ok' }} {{ object.self.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }} {{ object.undefinedMethod.self |default('default') is same as('default') ? 'ok' : 'ko' }} --DATA-- return [ 'definedVar' => 'defined', 'zeroVar' => 0, 'emptyVar' => '', 'nullVar' => null, 'nested' => [ 'definedVar' => 'defined', 'zeroVar' => 0, 'emptyVar' => '', 'nullVar' => null, 'definedArray' => [0], ], 'object' => new Twig\Tests\TwigTestFoo(), ] --CONFIG-- return ['strict_variables' => false] --EXPECT-- Variable: ok ok ok ok ok Array access: ok ok ok ok ok ok ok ok ok Plain values: ok ok ok ok Precedence: ok ok Object methods: ok ok ok ok ok ok Deep nested: ok ok ok ok ok ok ok ok --DATA-- return [ 'definedVar' => 'defined', 'zeroVar' => 0, 'emptyVar' => '', 'nullVar' => null, 'nested' => [ 'definedVar' => 'defined', 'zeroVar' => 0, 'emptyVar' => '', 'nullVar' => null, 'definedArray' => [0], ], 'object' => new Twig\Tests\TwigTestFoo(), ] --CONFIG-- return ['strict_variables' => true] --EXPECT-- Variable: ok ok ok ok ok Array access: ok ok ok ok ok ok ok ok ok Plain values: ok ok ok ok Precedence: ok ok Object methods: ok ok ok ok ok ok Deep nested: ok ok ok ok ok ok ok ok
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
abs.test | File | 391 B | 0644 |
|
batch.test | File | 694 B | 0644 |
|
batch_float.test | File | 667 B | 0644 |
|
batch_with_empty_fill.test | File | 563 B | 0644 |
|
batch_with_exact_elements.test | File | 772 B | 0644 |
|
batch_with_fill.test | File | 575 B | 0644 |
|
batch_with_keys.test | File | 250 B | 0644 |
|
batch_with_more_elements.test | File | 535 B | 0644 |
|
batch_with_zero_elements.test | File | 148 B | 0644 |
|
column.test | File | 311 B | 0644 |
|
convert_encoding.test | File | 218 B | 0644 |
|
date.test | File | 2.35 KB | 0644 |
|
date_default_format.test | File | 316 B | 0644 |
|
date_default_format_interval.test | File | 331 B | 0644 |
|
date_immutable.test | File | 984 B | 0644 |
|
date_interval.test | File | 420 B | 0644 |
|
date_modify.test | File | 339 B | 0644 |
|
date_namedargs.test | File | 418 B | 0644 |
|
default.test | File | 4.19 KB | 0644 |
|
dynamic_filter.test | File | 128 B | 0644 |
|
escape.test | File | 106 B | 0644 |
|
escape_html_attr.test | File | 199 B | 0644 |
|
escape_javascript.test | File | 133 B | 0644 |
|
escape_non_supported_charset.test | File | 148 B | 0644 |
|
filter.test | File | 1.39 KB | 0644 |
|
first.test | File | 251 B | 0644 |
|
force_escape.test | File | 295 B | 0644 |
|
format.test | File | 137 B | 0644 |
|
join.test | File | 782 B | 0644 |
|
json_encode.test | File | 229 B | 0644 |
|
last.test | File | 244 B | 0644 |
|
length.test | File | 1.05 KB | 0644 |
|
length_utf8.test | File | 177 B | 0644 |
|
map.test | File | 872 B | 0644 |
|
merge.test | File | 553 B | 0644 |
|
nl2br.test | File | 377 B | 0644 |
|
number_format.test | File | 300 B | 0644 |
|
number_format_default.test | File | 446 B | 0644 |
|
reduce.test | File | 264 B | 0644 |
|
replace.test | File | 446 B | 0644 |
|
replace_invalid_arg.test | File | 314 B | 0644 |
|
reverse.test | File | 427 B | 0644 |
|
round.test | File | 257 B | 0644 |
|
slice.test | File | 996 B | 0644 |
|
sort.test | File | 261 B | 0644 |
|
sort_with_arrow.test | File | 490 B | 0644 |
|
spaceless.test | File | 163 B | 0644 |
|
special_chars.test | File | 94 B | 0644 |
|
split.test | File | 535 B | 0644 |
|
split_utf8.test | File | 470 B | 0644 |
|
static_calls.test | File | 170 B | 0644 |
|
trim.test | File | 686 B | 0644 |
|
urlencode.test | File | 492 B | 0644 |
|