http://codereview.appspot.com/65052/diff/1/2 File java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/DefaultTemplateProcessor.java (right):
http://codereview.appspot.com/65052/diff/1/2#newcode446 Line 446: buffer.append("}).apply(e);"); Might be easier to add an ID to the original inserted node (or use existing ID). Pseudo-code String id = el.getAttribute("id") if (id == null) { id = generateUniqueId(); el.setAttribute(id); } .... buffer.append("}.apply(document.getElementById('" + jsEscape(id) + "')"); http://codereview.appspot.com/65052

