Expand description
§Include Handlebars Templates for Rocket Framework
This is a crate which provides macros handlebars_resources_initialize!
and handlebars_response!
to statically include HBS (Handlebars) files from your Rust project and make them be the HTTP response sources quickly.
handlebars_resources_initialize!
is used in the fairing ofHandlebarsResponse
to include Handlebars files into your executable binary file. You need to specify each file’s name and its path relative to the directory containing the manifest of your package. In order to reduce the compilation time and allow to hot-reload templates, files are compiled into your executable binary file together, only when you are using the release profile.handlebars_response!
is used for retrieving and rendering the file you input through the macrohandlebars_resources_initialize!
as aHandlebarsResponse
instance with rendered HTML. When itsrespond_to
method is called, three HTTP headers, Content-Type, Content-Length and Etag, will be automatically added, and the rendered HTML can optionally not be minified.handlebars_response_cache!
is used for wrapping aHandlebarsResponse
and its constructor, and use a key to cache its HTML and ETag in memory. The cache is generated only when you are using the release profile.handlebars_resources_initializer!
is used for generating a fairing for handlebars resources.
See examples
.
Macros§
- handlebars_
helper - Macro that allows you to quickly define a handlebars helper by passing a name and a closure.
- handlebars_
resources_ initialize - Used in the fairing of
HandlebarsResponse
to include Handlebars files into your executable binary file. You need to specify each file’s name and its path relative to the directory containing the manifest of your package. In order to reduce the compilation time and allow to hot-reload templates, files are compiled into your executable binary file together, only when you are using the release profile. - handlebars_
resources_ initializer - Used for generating a fairing for handlebars resources.
- handlebars_
response - Used for retrieving and rendering the file you input through the macro
handlebars_resources_initialize!
as aHandlebarsResponse
instance with rendered HTML. When itsrespond_to
method is called, three HTTP headers, Content-Type, Content-Length and Etag, will be automatically added, and the rendered HTML can optionally not be minified. - handlebars_
response_ cache - Used for wrapping a
HandlebarsResponse
and its constructor, and use a key to cache its HTML and ETag in memory. The cache is generated only when you are using the release profile.
Structs§
- Entity
Tag - An entity tag, defined in RFC7232.
- Etag
IfNone Match - The request guard used for getting
if-none-match
header. - Handlebars
Context Manager - To monitor the state of Handlebars.
- Handlebars
Response - To respond HTML.
- Handlebars
Response Fairing - The fairing of
HandlebarsResponse
. - Reloadable
Handlebars - Reloadable Handlebars.