gws.plugin.template.html

HTML template.

This module handles templates written in the Jump language. Apart from html, this template can generate pdf (for printing) and image outputs.

The arguments passed to a template can be accessed via the _ARGS object.

If a template explicitly returns a gws.Response object, the generated text is ignored and the object is returned as a render result. Otherwise, the result of the rendering will be a gws.ContentResponse object with the generated content.

This template supports the following extensions to Jump:

The @page command, which sets parameters for the printed page:

@page (
    width="<page width in mm>"
    height="<page height in mm>"
    margin="<page margins in mm>"
)

The @map command, which renders the current map:

@map (
    width="<width in mm>"
    height="<height in mm>"
    bbox="<optional, bounding box in projection units>"
    center="<optional, center coordinates in projection units>"
    scale="<optional, scale factor>"
    rotation="<optional, rotation in degrees>"

The @legend command, which renders the map legend:

@legend(
    layers="<optional, space separated list of layer UIDs>"
)

The @header and @footer block commands, which define headers and footers for multi-page printing:

@header
    content
@end header

@footer
    content
@end footer

Headers and footers are separate sub-templates, which receive the same arguments as the main template and two additional arguments:

  • numpages - the total number of pages in the document

  • page - the current page number

Source code: gws.plugin.template.html

Package Contents

class gws.plugin.template.html.Config

Bases: gws.base.template.Config

path: gws.FilePath | None

path to a template file

text: str = ''

template content

class gws.plugin.template.html.Engine(template: Object, tri: gws.TemplateRenderInput | None = None)

Bases: gws.lib.vendor.jump.Engine

footer: str = ''
header: str = ''
pageMargin: list[int] = []
pageSize: gws.UomSize = []
def_legend(**kw)
def_map(**kw)
def_page(**kw)
mbox_header(text)
class gws.plugin.template.html.Object

Bases: gws.base.template.Object

compiledFn
compiledTime: float = 0
path: str
text: str
compile(engine: Engine)
configure()
decorate_html(html)
error_handler(exc, path, line, env)
finalize(tri: gws.TemplateRenderInput, html: str, args: dict, main_engine: Engine)
finalize_pdf(tri: gws.TemplateRenderInput, html: str, args: dict, main_engine: Engine)
finalize_png(tri: gws.TemplateRenderInput, html: str, args: dict, main_engine: Engine)
frame_template(header, footer, page_size)
render(tri)
render_legend(tri: gws.TemplateRenderInput, index, layers)
render_map(tri: gws.TemplateRenderInput, width, height, index, bbox=None, center=None, scale=None, rotation=None)
class gws.plugin.template.html.Props

Bases: gws.base.template.Props