Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmed-musallam/9b2eb2f5c6743fb81f6508762799a5d0 to your computer and use it in GitHub Desktop.
Save ahmed-musallam/9b2eb2f5c6743fb81f6508762799a5d0 to your computer and use it in GitHub Desktop.
A snippet to extract AEM Granite UI widget doc as json
// 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