I want to render in a template an image that originates from a ClientBundle. But what I get instead is this:
<img="#">
I've checked the contents of the datasource and if I copy the image (data:image/png;base64...) in {0} it works.
Why it doesn't work if I pass it as a parameter?
DataResource inputCheckImage = MGWTStyle.getTheme().getMGWTClientBundle().inputCheckImage();
private static Template TEMLPATE = GWT.create(Template.class);
public interface Template extends SafeHtmlTemplates
{
@SafeHtmlTemplates.Template("<div><img src=\"{0}\"></div>")
SafeHtml content(String image);
}
//@Override
public void render(SafeHtmlBuilder safeHtmlBuilder, Action model) {
SafeUri url = inputCheckImage.getSafeUri();
SafeHtml safeHtml = TEMLPATE.content(url.asString());
safeHtmlBuilder.append(safeHtml);
}
Use SafeUri as the argument type on your template, otherwise the value will be sanitized and a data: URI is considered unsafe.