Created
September 4, 2012 22:18
-
-
Save pdp7/3627333 to your computer and use it in GitHub Desktop.
GistMacro
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
public void execute(Element element, RenderContext renderContext) { | |
if (element.getTextContent() == null || element.getTextContent().length() == 0) { | |
return; | |
} | |
String id = (String) getParameters().get(GIST_ID); | |
if (id != null && !id.trim().equals("")) { | |
Element wrapper = JAXPUtils.createElement(element.getOwnerDocument(), "span"); | |
Element script = JAXPUtils.createElement(element, "script"); | |
script.setAttribute("type", "text/javascript"); | |
script.setAttribute("src", "https://gist.github.com/" + id + ".js"); | |
wrapper.appendChild(script); | |
RendererUtil.flagAsExcluded(wrapper, renderContext); | |
JAXPUtils.replace(element, wrapper); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment