public interface TemplateEngine
StaticFileHandler and EmbeddedResourceHandler.
Webbit itself doesn't provide any template engines. Look at Webbit-REST
for implementations.| 限定符和类型 | 字段和说明 |
|---|---|
static String |
TEMPLATE_CONTEXT |
byte[] process(byte[] template,
String templatePath,
Object templateContext)
throws RuntimeException
templateContext with a template to produce output. What constitutes a valid
context is template-engine specific.
Rendering happens on your main thread, so it is important that this method is not IO-bound. For example,
rendering a template using a context that is some sort of active record
that makes trips to the database will block Webbit preventing it from handling other requests. It's important to
make sure any remote data is pre-fetched.
Webbit will pass the request data value keyed with TEMPLATE_CONTEXT as the templateContext argument.
It's the programmer's responsibility to make sure the data value is set before the template is rendered,
i.e. before the StaticFileHandler or EmbeddedResourceHandler handler instance handles a request.length - number of bytes in the templatetemplate - the template sourcetemplatePath - the path the template is read from. Allows implementations to cache compiled templates.templateContext - object to merge into the templateRuntimeExceptionDataHolder.data(String),
HttpRequest.data(String, Object)Copyright © 2014. All rights reserved.