public interface Renderable
Context.render(Object)
.
A Renderer
for this type is provided by Ratpack core, that simply delegates to render(Context)
.
An alternative to providing a Renderer
implementation for a type is to make the type implement this interface.
import ratpack.handling.Context;
import ratpack.render.Renderable;
import ratpack.test.embed.EmbeddedApp;
import static org.junit.Assert.*;
public class Example {
static class Thing implements Renderable {
public void render(Context context) {
context.render("thing!");
}
}
static void main(String... args) {
EmbeddedApp.fromHandler(ctx ->
ctx.render(new Thing())
).test(httpClient ->
assertEquals("thing!", httpClient.getText())
);
}
}
An alternative to making a type implement this interface, is implementing a Renderer
for it.
Modifier and Type | Method and Description |
---|---|
void |
render(Context context)
Render this object to the response.
|