mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Allow boolean tree attributes (attributes with no value)
This commit is contained in:
parent
4cc45009b4
commit
1eded7b2ae
@ -66,14 +66,16 @@ TypeConverter.convert = function (value, targetType, allowExpressions) {
|
||||
if (targetType === 'string') {
|
||||
return allowExpressions ? new Expression(value != null ? stringify(value) : 'null') : value;
|
||||
} else if (targetType === 'boolean') {
|
||||
if (allowExpressions) {
|
||||
return new Expression(value);
|
||||
} else {
|
||||
if (!allowExpressions) {
|
||||
value = value.toLowerCase();
|
||||
value = value === 'true' || value === 'yes';
|
||||
//convert it to a boolean
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!allowExpressions || value === 'true' || value === 'yes' || value === '') {
|
||||
//convert it to a boolean
|
||||
return new Expression(true);
|
||||
}
|
||||
|
||||
return new Expression(value);
|
||||
} else if (targetType === 'float' || targetType === 'double' || targetType === 'number' || targetType === 'integer' || targetType === 'int') {
|
||||
if (allowExpressions) {
|
||||
return new Expression(value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user