Created
July 20, 2017 02:45
-
-
Save ahmed-musallam/9b2eb2f5c6743fb81f6508762799a5d0 to your computer and use it in GitHub Desktop.
A snippet to extract AEM Granite UI widget doc as json
This file contains 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
// you can run this code in chrome on this link for example: https://docs.adobe.com/docs/en/aem/6-2/develop/ref/granite-ui/api/jcr_root/libs/granite/ui/components/coral/foundation/form/checkbox/index.html | |
// get textContent of child element based on selector | |
function getText(el, selector){ | |
if(!el) return; | |
var childEl = el.querySelector(selector); | |
return childEl ? childEl.textContent : "" | |
} | |
$(".propertydef").each((a,p) => | |
{ | |
var name = getText(p, ".propertyname"); | |
var type = getText(p, ".propertytype"); | |
var description = getText(p, "dd"); | |
var gndAttributes = getText(p, ".gnd-attributes"); | |
var detailObj = {name:name, type:type, description:description, gndAttributes:gndAttributes }; | |
console.log(detailObj) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment