packages/okam-build/lib/processor/template/transform/base/class.js
function transformObjClass(value, objToStr) {
    value = value.replace(/[\s*{}]/g, '').split(',').map(item => {
        const arr = item.split(':');
        let key = arr[0];
        let firstChar = key.charAt(0);
        if (firstChar !== '\'' && firstChar !== '\"') {
            key = `'${key}'`;
        }

        // support object abbrev case: {a, b}
        let expression = arr.length === 1 ? arr[0] : arr[1];
        let result = `${expression}?${key}:''`;

        return objToStr ? `(${result})` : result;
    });
    return value.join(objToStr ? ' + \' \' + ' : ',');
}
function transformObjClass(value, objToStr) {
    value = value.replace(/[\s*{}]/g, '').split(',').map(item => {
        const arr = item.split(':');
        let key = arr[0];
        let firstChar = key.charAt(0);
        if (firstChar !== '\'' && firstChar !== '\"') {
            key = `'${key}'`;
        }

        // support object abbrev case: {a, b}
        let expression = arr.length === 1 ? arr[0] : arr[1];
        let result = `${expression}?${key}:''`;

        return objToStr ? `(${result})` : result;
    });
    return value.join(objToStr ? ' + \' \' + ' : ',');
}
function transformObjClass ( value , objToStr ) { value = value . replace ( / [\s*{}] / g , '' ) . split ( ',' ) . map ( item => { const arr = item . split ( ':' ) ; let key = arr [ 0 ] ; let firstChar = key . charAt ( 0 ) ; if ( firstChar !== '\'' && firstChar !== '\"' ) { key = ` ${ key } ` ; } // support object abbrev case: {a, b} let expression = arr . length === 1 ? arr [ 0 ] : arr [ 1 ] ; let result = ` ${ expression } ${ key } ` ; return objToStr ? ` ${ result } ` : result ; } ) ; return value . join ( objToStr ? ' + \' \' + ' : ',' ) ; }
transform object syntax class
eg: { active: isActive } -> [isActive ? 'active' : '']

@param {string} value   string to be transformed
@param {boolean=} objToStr whether convert object syntax to string, by default false
@return {string} transformed result
transform object syntax class eg : { active : isActive } - > [ isActive ? active : ]