{{ undefinedVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
Array access:
{{ nested.definedVar |default('default') is sameas('default') ? 'ko' : 'ok' }}
+{{ nested['definedVar'] |default('default') is sameas('default') ? 'ko' : 'ok' }}
{{ nested.zeroVar |default('default') is sameas('default') ? 'ko' : 'ok' }}
{{ nested.emptyVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
{{ nested.nullVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
{{ nested.undefinedVar |default('default') is sameas('default') ? 'ok' : 'ko' }}
+{{ nested['undefinedVar'] |default('default') is sameas('default') ? 'ok' : 'ko' }}
{{ undefinedVar.foo |default('default') is sameas('default') ? 'ok' : 'ko' }}
Plain values:
{{ 'defined' |default('default') is sameas('default') ? 'ko' : 'ok' }}
Precedence:
{{ 'o' ~ nullVar |default('k') }}
{{ 'o' ~ nested.nullVar |default('k') }}
+Object methods:
+{{ object.foo |default('default') is sameas('default') ? 'ko' : 'ok' }}
+{{ object.undefinedMethod |default('default') is sameas('default') ? 'ok' : 'ko' }}
Deep nested:
{{ nested.undefinedVar.foo.bar |default('default') is sameas('default') ? 'ok' : 'ko' }}
{{ nested.definedArray.0 |default('default') is sameas('default') ? 'ko' : 'ok' }}
+{{ nested['definedArray'][0] |default('default') is sameas('default') ? 'ko' : 'ok' }}
+{{ object.self.foo |default('default') is sameas('default') ? 'ko' : 'ok' }}
+{{ object.self.undefinedMethod |default('default') is sameas('default') ? 'ok' : 'ko' }}
+{{ object.undefinedMethod.self |default('default') is sameas('default') ? 'ok' : 'ko' }}
--DATA--
return array(
'definedVar' => 'defined',
'nullVar' => null,
'definedArray' => array(0),
),
+ 'object' => new Foo(),
)
--CONFIG--
return array('strict_variables' => false)
ok
ok
ok
+ok
+ok
Plain values:
ok
ok
Precedence:
ok
ok
+Object methods:
+ok
+ok
Deep nested:
ok
ok
+ok
+ok
+ok
+ok
--DATA--
return array(
'definedVar' => 'defined',
'nullVar' => null,
'definedArray' => array(0),
),
+ 'object' => new Foo(),
)
--CONFIG--
return array('strict_variables' => true)
ok
ok
ok
+ok
+ok
Plain values:
ok
ok
Precedence:
ok
ok
+Object methods:
+ok
+ok
Deep nested:
ok
ok
+ok
+ok
+ok
+ok
{{ zeroVar is defined ? 'ok' : 'ko' }}
{{ nullVar is defined ? 'ok' : 'ko' }}
{{ nested.definedVar is defined ? 'ok' : 'ko' }}
+{{ nested['definedVar'] is defined ? 'ok' : 'ko' }}
{{ nested.definedVar is not defined ? 'ko' : 'ok' }}
{{ nested.undefinedVar is defined ? 'ko' : 'ok' }}
+{{ nested['undefinedVar'] is defined ? 'ko' : 'ok' }}
{{ nested.undefinedVar is not defined ? 'ok' : 'ko' }}
{{ nested.zeroVar is defined ? 'ok' : 'ko' }}
{{ nested.nullVar is defined ? 'ok' : 'ko' }}
{{ nested.definedArray.0 is defined ? 'ok' : 'ko' }}
+{{ nested['definedArray'][0] is defined ? 'ok' : 'ko' }}
+{{ object.foo is defined ? 'ok' : 'ko' }}
+{{ object.undefinedMethod is defined ? 'ko' : 'ok' }}
+{{ object.self.foo is defined ? 'ok' : 'ko' }}
+{{ object.self.undefinedMethod is defined ? 'ko' : 'ok' }}
+{{ object.undefinedMethod.self is defined ? 'ko' : 'ok' }}
--DATA--
return array(
'definedVar' => 'defined',
'zeroVar' => 0,
'nullVar' => null,
'definedArray' => array(0),
- )
+ ),
+ 'object' => new Foo(),
);
--EXPECT--
ok
ok
ok
ok
+ok
+ok
+ok
+ok
+ok
+ok
+ok
+ok
--DATA--
return array(
'definedVar' => 'defined',
'zeroVar' => 0,
'nullVar' => null,
'definedArray' => array(0),
- )
+ ),
+ 'object' => new Foo(),
);
--CONFIG--
return array('strict_variables' => false)
ok
ok
ok
+ok
+ok
+ok
+ok
+ok
+ok
+ok
+ok