Skip to content

Instantly share code, notes, and snippets.

@RauliL
Last active January 20, 2016 07:41
Show Gist options
  • Save RauliL/9913ec05077422dbf1da to your computer and use it in GitHub Desktop.
Save RauliL/9913ec05077422dbf1da to your computer and use it in GitHub Desktop.
JavaScript: Globals object.
window.Globals = (function() {
var result = {};
$("meta[name^='global:']").each(function() {
var tag = $(this);
var name = tag.attr("name").substring(7);
var content = tag.attr("content");
if (/^json:/.test(name)) {
name = name.substring(5);
content = JSON.parse(content);
}
result[name] = content;
});
return result;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment