org.webbitserver.handler
Class StaticFile
java.lang.Object
org.webbitserver.handler.StaticFile
- All Implemented Interfaces:
- TemplateEngine
public class StaticFile
- extends Object
- implements TemplateEngine
|
Method Summary |
byte[] |
process(byte[] template,
String templatePath,
Object templateContext)
Renders a template. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StaticFile
public StaticFile()
process
public byte[] process(byte[] template,
String templatePath,
Object templateContext)
- Description copied from interface:
TemplateEngine
- Renders a template.
Most template engines merge a
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 TemplateEngine.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.
- Specified by:
process in interface TemplateEngine
- Parameters:
template - the template sourcetemplatePath - the path the template is read from. Allows implementations to cache compiled templates.templateContext - object to merge into the template
- Returns:
- a rendered template
- See Also:
DataHolder.data(String),
HttpRequest.data(String, Object)
Copyright © 2013. All Rights Reserved.