diff --git a/src/constants.js b/src/constants.js index fb81dee..31612cc 100644 --- a/src/constants.js +++ b/src/constants.js @@ -78,6 +78,26 @@ function getType(v) { ? { type: Array, default: v } : { type: Object, default: v } + case 'string': + let type = String + let attribute = true + if (v.includes('!')) { + v = v.split('!') + let _t = v.shift() + if (_t === 'str') { + v = v.join('!') + } else if (_t === 'num') { + type = Number + v = +v.shift() || 0 + } else if (_t === 'bool') { + type = Boolean + v = v.shift() + v = v !== 'false' && v !== '' + } + attribute = false + } + return { type, default: v, attribute } + default: return { type: String, default: v + '' } }