Created
August 21, 2015 08:06
-
-
Save uiur/322f9a83cd549e5ddf93 to your computer and use it in GitHub Desktop.
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
var qwery = require('qwery') | |
var unescape = require('lodash/string/unescape') | |
module.exports = function () { | |
return qwery('script[type="application/json"]').reduce(function (obj, el) { | |
var key = el.getAttribute('data-key') | |
if (key) { | |
try { | |
obj[key] = JSON.parse(unescape(el.textContent)) | |
} catch (e) { | |
} | |
} | |
return obj | |
}, {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment