el-component
Advanced tools
Comparing version 0.0.0 to 0.1.0
@@ -5,3 +5,3 @@ { | ||
"description": "creates HTML from jade like expressions", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"keywords": [], | ||
@@ -15,2 +15,2 @@ "dependencies": {}, | ||
] | ||
} | ||
} |
26
index.js
module.exports = el; | ||
// see: http://www.w3.org/html/wg/drafts/html/master/single-page.html#void-elements | ||
var voids = [ | ||
'area', 'base', 'br', 'col', 'embed', | ||
'hr', 'img', 'input', 'keygen', 'link', | ||
'menuitem', 'meta', 'param', 'source', 'track', 'wbr' | ||
]; | ||
function el(tag, content, attrs) { | ||
var attrStr, classes, ids; | ||
var attrStr, classes, ids, text; | ||
@@ -36,11 +42,17 @@ if (typeof content !== 'string') { | ||
return ['<', | ||
text = ['<', | ||
tag, | ||
attrStr ? ' ' + attrStr : '', | ||
'>', | ||
content, | ||
'</', | ||
tag, | ||
'>' | ||
].join(''); | ||
]; | ||
if(voids.indexOf(tag) < 0) { | ||
text = text.concat([ | ||
content, | ||
'</', | ||
tag, | ||
'>' | ||
]); | ||
} | ||
return text.join(''); | ||
} |
{ | ||
"name": "el-component", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "create HTML from jade-like expressions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,2 +29,8 @@ var el = require('..'); | ||
}); | ||
it('should treat void elements differently from non void elements', function() { | ||
el('img', { src: 'http://example.com/img.png' }).should.eql('<img src="http://example.com/img.png">'); | ||
el('iframe', { src: 'http://example.com' }).should.eql('<iframe src="http://example.com"></iframe>'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4308
88