Marko v3: Helper method to return an attributes literal value if it has a literal value

This commit is contained in:
Patrick Steele-Idem 2016-02-03 11:19:29 -07:00
parent dfdbf8b377
commit 07e513c6ff

View File

@ -180,6 +180,14 @@ class HtmlAttribute extends Node {
walk(walker) {
this.value = walker.walk(this.value);
}
get literalValue() {
if (this.isLiteralValue()) {
return this.value.value;
} else {
throw new Error('Attribute value is not a literal value. Actual: ' + JSON.stringify(this.value, null, 2));
}
}
}
HtmlAttribute.isHtmlAttribute = function(attr) {