Package ratpack.core.render
Interface Renderable
-
- All Known Implementing Classes:
Markup
,ResponseChunks
,ServerSentEvents
public interface Renderable
A renderable object, that can be given toContext.render(Object)
.A
Renderer
for this type is provided by Ratpack core, that simply delegates torender(Context)
. An alternative to providing aRenderer
implementation for a type is to make the type implement this interface.import ratpack.core.handling.Context; import ratpack.core.render.Renderable; import ratpack.test.embed.EmbeddedApp; import static org.junit.jupiter.api.Assertions.*; public class Example { static class Thing implements Renderable { public void render(Context context) { context.render("thing!"); } } static void main(String... args) throws Exception { 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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
render(Context context)
Render this object to the response.
-