Skip to content

Instantly share code, notes, and snippets.

@pdp7
Created September 4, 2012 22:18
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 pdp7/3627333 to your computer and use it in GitHub Desktop.
Save pdp7/3627333 to your computer and use it in GitHub Desktop.
GistMacro
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