html-code-gen
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -44,3 +44,6 @@ /** | ||
var printVoidElementNode = function (info, node, condition, opt) { | ||
return util.format('<${tag}${attributes}>', info); | ||
var tpl = opt['self-close'] === 'close' | ||
? '<${tag}${attributes} />' | ||
: '<${tag}${attributes}>'; | ||
return util.format(tpl, info); | ||
}; | ||
@@ -50,9 +53,9 @@ | ||
return ( | ||
content ? | ||
[ | ||
content | ||
? [ | ||
info.start, | ||
content, | ||
info.end | ||
] : | ||
[ | ||
] | ||
: [ | ||
info.start, | ||
@@ -81,8 +84,8 @@ info.end | ||
var content = node.childNodes.length ? | ||
formatter(node.childNodes[0].textContent, node, contentOpt, { | ||
var content = node.childNodes.length | ||
? formatter(node.childNodes[0].textContent, node, contentOpt, { | ||
indent: indentContent, | ||
trim: removeBlankLineAround | ||
}) : | ||
''; | ||
}) | ||
: ''; | ||
@@ -94,4 +97,4 @@ return packageElement(info, content); | ||
var content = ( | ||
condition.newLine ? | ||
info.children.map(function (child) { | ||
condition.newLine | ||
? info.children.map(function (child) { | ||
child = child.trim(); | ||
@@ -101,4 +104,4 @@ return child ? (info.innerIndent + child) : child; | ||
return child; | ||
}) : | ||
info.children | ||
}) | ||
: info.children | ||
).join(info.sep); | ||
@@ -105,0 +108,0 @@ |
@@ -14,5 +14,5 @@ /** | ||
var printTextNode = function (node, opt) { | ||
return opt['no-format'] ? | ||
node.textContent : | ||
node.textContent.replace(/[\s\n\r]+/g, ' '); | ||
return opt['no-format'] | ||
? node.textContent | ||
: node.textContent.replace(/[\s\n\r]+/g, ' '); | ||
}; | ||
@@ -88,2 +88,4 @@ | ||
'bool-attribute-value': 'remove', | ||
// Should void tags close themeselves with "/" ( 'close' / 'no-close' ) | ||
'self-close': 'no-close', | ||
// current level | ||
@@ -90,0 +92,0 @@ 'level': 0 |
{ | ||
"name": "html-code-gen", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -80,4 +80,8 @@ html-code-gen | ||
default: `'remove'`, | ||
default: `'remove'` | ||
* `self-close`: should void tags close themeselves with "/" ( 'close' / 'no-close' ) | ||
default: `'no-close'` | ||
* `level`: current level | ||
@@ -84,0 +88,0 @@ |
94332
727
99