Adds a jinja2 transform type to the OGC Building Blocks postprocessor.
The transform renders a Jinja2 template against JSON input data, producing any text-based output (HTML, XML, plain text, etc.).
Declare the plugin in transform-plugins.yml at the root of your building blocks repository:
plugins:
- pip: git+https://github.com/ogcincubator/bblocks-jinja2-transform-plugin.git
modules:
- bbplugin_jinja2Then declare a jinja2 transform in your transforms.yaml:
transforms:
- id: html-summary
type: jinja2
inputs:
mediaTypes: [application/json]
outputs:
mediaTypes:
- mimeType: text/html
defaultExtension: html
code: |
<dl>
{% for key, value in data.items() %}
<dt>{{ key }}</dt><dd>{{ value }}</dd>
{% endfor %}
</dl>The JSON input is parsed and made available in two ways:
data— the full parsed value (works for objects, arrays, and primitives)- top-level keys — if the input is a JSON object, its keys are also injected directly as template variables
So given input {"name": "Alice", "role": "Engineer"}, both {{ data.name }} and {{ name }} resolve to "Alice".
Undefined variables raise an error (Jinja2 StrictUndefined).
- Python ≥ 3.10
- Jinja2 (installed automatically by the postprocessor)