Skip to content

Instantly share code, notes, and snippets.

@matori
Last active February 3, 2016 03:18
Show Gist options
  • Save matori/9ee10a0bc3d5d302f028 to your computer and use it in GitHub Desktop.
Save matori/9ee10a0bc3d5d302f028 to your computer and use it in GitHub Desktop.
Jade meta tag mixin
mixin meta(name, content)
-
var attrs = {};
var httpEquivRegExp = /^content-(?:encoding|length|language|type|(?:style|script)-type)|default-style|refresh|set-cookie|pragma|cache-control|expires|allow|date|last-modified|location|www-authenticate|x-(?:ua-compatible|dns-prefetch-control|rim-auto-match)$/i;
var ogpRegExp = /^og:/i;
name = typeof name === "string" ? name.trim() : null;
content = typeof content === "string" ? content.trim() : null;
if name && content
if name === "charset"
meta(charset="#{content}")&attributes(attributes)
else
if httpEquivRegExp.test(name)
- attrs["http-equiv"] = name;
else if ogpRegExp.test(name)
- attrs["property"] = name;
else
- attrs["name"] = name
meta(content="#{content}")&attributes(attrs)&attributes(attributes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment