SafeHtmlTemplates abstract class
A tag interface that facilitates compile-time binding of HTML templates to generate SafeHtml strings.
Example usage:
public interface MyTemplate extends SafeHtmlTemplates { @Template("<span class=\"{3}\">{0}: <a href=\"{1}\">{2}</a></span>") SafeHtml messageWithLink(SafeHtml message, String url, String linkText, String style); }private static final MyTemplate TEMPLATE = GWT.create(MyTemplate.class);
public void useTemplate(...) {
SafeHtml message; String url; String linkText; String style; // ... SafeHtml messageWithLink = TEMPLATE.messageWithLink(message, url, linkText, style);
} </pre>
Instantiating a {@code SafeHtmlTemplates} interface with {@code GWT.create()} returns an instance of an implementation that is generated at compile time. The code generator parses the value of each template method's {@code @Template} annotation as an HTML template, with template variables denoted by curly-brace placeholders that refer by index to the corresponding template method parameter.
The code generator's template parser is lenient, and will accept HTML that is not well-formed; the accepted set of HTML is similar to what is typically accepted by browsers. However, the following constraints on the HTML template are enforced:
- Template variables may not appear in a JavaScript context (inside a {@code