Last active
February 3, 2016 03:18
-
-
Save matori/9ee10a0bc3d5d302f028 to your computer and use it in GitHub Desktop.
Jade meta tag mixin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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