import * as regexps from './regexps'; import { camelize } from './string/camelize'; export class ASTItem { protected raw: string; public isBlock: boolean; public isElement: boolean; public isModifier: boolean; public name: string; public parentBlock: string; public rawname: string; public value: string; constructor(inputstring: string) { let sanitized = inputstring.replace(regexps.REGEXP_SANITIZER, ''); let splitted = sanitized.split('='); this.name = camelize(splitted[0].trim()); this.raw = inputstring; this.rawname = splitted[0].trim(); this.value = splitted[1].trim().replace(/\./g, ' ').trim(); this.isElement = regexps.REGEXP_ELEMENT.test(this.rawname); this.isModifier = regexps.REGEXP_MODIFIER.test(this.rawname); this.isBlock = !this.isElement && !this.isModifier; this.parentBlock = camelize(this.rawname.split(/__|--/g)[0]); } }