From 3e4f8893ddf129ab1f967993a092d33f1dd4d44f Mon Sep 17 00:00:00 2001 From: Sebastian Castro Date: Thu, 29 Oct 2020 14:07:29 +0100 Subject: [PATCH] Allow attributes with empty value `%input(checked)` => `` --- lib/haml.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/haml.js b/lib/haml.js index b726905..8ce8949 100755 --- a/lib/haml.js +++ b/lib/haml.js @@ -22,10 +22,12 @@ var Haml; } if (key !== '_content' && attribs.hasOwnProperty(key)) { switch (attribs[key]) { - case 'undefined': case 'false': + break; + case 'undefined': case 'null': case '""': + result.push(" " + key); break; default: try { @@ -80,6 +82,10 @@ var Haml; value = line.substr(pair.middle + 1, pair.end - pair.middle - 1).trim(); attributes[key] = value; } + else if (typeof pair.start === 'number' && typeof pair.end === 'number') { + var key = line.substr(pair.start, pair.end - pair.start).trim() + if (key != "") attributes[key] = "" + } pair = { start: null, middle: null, @@ -193,6 +199,7 @@ var Haml; tag = tag ? tag[0].substr(1, tag[0].length) : 'div'; attribs = this.matches[3]; + if (attribs) { attribs = parse_attribs(attribs); if (attribs._content) {