Skip to content

Instantly share code, notes, and snippets.

@L8D
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L8D/9ee64f5fc131ea4cdf1b to your computer and use it in GitHub Desktop.
Save L8D/9ee64f5fc131ea4cdf1b to your computer and use it in GitHub Desktop.
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(zt);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.zt = factory();
}
})(this, function() {
var zt = function(tag) {
return function(attrs) {
var innards = Array.prototype.slice.call(arguments, 1),
str = '<' + tag;
if (typeof attrs === 'string') {
innards.unshift(attrs);
} else if (typeof attrs === 'object') {
for (var prop in attrs) {
str += ' ' + prop + '="' + attrs[prop] + '"';
}
}
return str + '>' + innards.join('') + '</' + tag + '>';
};
};
var wt = function(tag) {
return function(attrs) {
var str = '<' + tag;
if (typeof attrs === 'object') {
for (var prop in attrs) {
str += ' ' + prop + '="' + attrs[prop] + '"';
}
}
return str + '>';
};
};
var tags = {
a: false,
abbr: false,
address: false,
area: true,
article: false,
aside: false,
audio: false,
b: false,
base: true,
bdi: false,
bdo: false,
big: false,
blockquote: false,
body: false,
br: true,
button: false,
canvas: false,
caption: false,
cite: false,
code: false,
col: true,
colgroup: false,
data: false,
datalist: false,
dd: false,
del: false,
details: false,
dfn: false,
div: false,
dl: false,
dt: false,
em: false,
embed: true,
fieldset: false,
figcaption: false,
figure: false,
footer: false,
form: false,
h1: false,
h2: false,
h3: false,
h4: false,
h5: false,
h6: false,
head: false,
header: false,
hr: true,
html: false,
i: false,
iframe: false,
img: true,
input: true,
ins: false,
kbd: false,
keygen: true,
label: false,
legend: false,
li: false,
link: true,
main: false,
map: false,
mark: false,
menu: false,
menuitem: false,
meta: true,
meter: false,
nav: false,
noscript: false,
object: false,
ol: false,
optgroup: false,
option: false,
output: false,
p: false,
param: true,
pre: false,
progress: false,
q: false,
rp: false,
rt: false,
ruby: false,
s: false,
samp: false,
script: false,
section: false,
select: false,
small: false,
source: true,
span: false,
strong: false,
style: false,
sub: false,
summary: false,
sup: false,
table: false,
tbody: false,
td: false,
textarea: false,
tfoot: false,
th: false,
thead: false,
time: false,
title: false,
tr: false,
track: true,
u: false,
ul: false,
'var': false,
video: false,
wbr: true,
// SVG
circle: false,
defs: false,
ellipse: false,
g: false,
line: false,
linearGradient: false,
mask: false,
path: false,
pattern: false,
polygon: false,
polyline: false,
radialGradient: false,
rect: false,
stop: false,
svg: false,
text: false,
tspan: false
};
for (var tag in tags) {
if (tags[tag]) {
tags[tag] = wt(tag);
} else {
tags[tag] = zt(tag);
}
}
return tags;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment