gws.plugin.template.text¶
Text templates.
The text template is written in the Jump template language, like the
html template, but has none of its custom commands (@map,
@legend, @page and so on) and produces text output only. The
output MIME type is the mimeOut of the render input, or the first
configured mimeTypes entry, or plain text. If a template explicitly
returns a gws.Response object, it is returned as the render result.
Example:
templates+ {
subject "feature.label"
type "text"
text "{{name}}"
}
Source code: gws.plugin.template.text
Package Contents¶
- class gws.plugin.template.text.Config¶
Bases:
gws.base.template.ConfigJump template for plain text output.
- path: gws.FilePath | None¶
Template file.
- class gws.plugin.template.text.Engine¶
Bases:
gws.lib.vendor.jump.EngineJump engine for text templates, without custom commands.
- class gws.plugin.template.text.Object¶
Bases:
gws.base.template.ObjectJump template for text output.
- compiledFn = None¶
Compiled template function.
- compile(engine: Engine)¶
Compile the template if needed.
The template file is read again if it has changed since the last compilation. With the developer option
template.always_reload, the template is compiled on each call; withtemplate.save_compiled, the translated source is written to a debug file.- Parameters:
engine – Jump engine.
- configure()¶
- error_handler(exc, path, line, env)¶
Handle a template runtime error.
The error is logged. With the developer option
template.raise_errors, the error is raised, otherwise rendering continues.- Parameters:
exc – The exception.
path – Template path.
line – Template line.
env – Template environment.
- Returns:
Trueto continue rendering,Falseto raise the error.
- finalize(tri: gws.TemplateRenderInput, res: str, args: dict, main_engine: Engine)¶
Wrap the generated text in a content response.
- Parameters:
tri – Template render input.
res – Generated text.
args – Template arguments.
main_engine – Engine that rendered the text.
- Returns:
Content response.
- render(tri)¶
- class gws.plugin.template.text.Props¶
Bases:
gws.base.template.Props