@Override public String getHTML() { if (tmpTpl != null) { String tt = tmpTpl; tmpTpl = null; return tt; } try { String html = this.getCompiler().compile(getTemplate(), getContext()); if (forceStyle) { Source source = new Source(html); Attributes attrs = source.getFirstElement().getAttributes(); if (attrs != null) { // id // class // style // name for (int i = 0; i < attrs.size(); i++) { Attribute attr = attrs.get(i); String name = attr.getName(); String value = attr.getValue(); // System.out.println(name + ":" + value); if (name.equals("id")) { this.id = attr.getValue(); } else { setAttribute(name, value); } } } html = JavascriptUtil.javaScriptEscape(html); tmpTpl = html; } else { html = JavascriptUtil.javaScriptEscape(html); } return html; } catch (Exception e) { e.printStackTrace(); return "<h1>There was an error<h1><p>" + JavascriptUtil.javaScriptEscape(e.getMessage()) + "</p>"; // throw new IllegalStateException(e); } }