Skip to main content

A templating engine for SPARQL queries with typed, injection-safe placeholders and loops

Project description

Triplate (Python)

A templating engine for RDF query & data languages (SPARQL, Turtle, …) with a typed --- frontmatter header, injection-safe values, loops and conditionals. Python reference implementation of the Triplate language.

from triplate import compile

template = """\
---
params {
  classes: iri[] min 1
  limit:   int optional
}
---
SELECT ?s WHERE {
{% for c in classes join "UNION" %}
  { ?s a ${c} }
{% endfor %}
}
{% if limit %}LIMIT ${limit}{% endif %}
"""

tmpl = compile(template)
sparql = tmpl.render(classes=["http://example.org/Person"], limit=10)

Every input is declared in the mandatory --- frontmatter header with its RDF type; the context is validated and each value escaped accordingly, so rendered output is injection-safe and an unprocessed template fails fast.

See triplate.dev for the full guide and specification.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

triplate-0.5.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

triplate-0.5.1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file triplate-0.5.1.tar.gz.

File metadata

  • Download URL: triplate-0.5.1.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplate-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b6dff981e6f23ed4119c0b87e97d789c1001ee4466b412c46e8a27b9c6ae0c17
MD5 aca1077c7fa93d697d098972c8c57525
BLAKE2b-256 fdd19f1a435143e832177454338f8089abe48c90addbc254b5d168e4feaab2f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplate-0.5.1.tar.gz:

Publisher: release-please.yml on triplate/triplate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplate-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: triplate-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplate-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9086e9410b856bf389452947308a07ed0681e1d76b677f01371ae984505d71a1
MD5 e2e107e642b5a332a6587d6b7dd00be3
BLAKE2b-256 8dd1f124c8bd12ae4bcd1495566060f3eab5be8e0419ff595c15cc416a627ad9

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplate-0.5.1-py3-none-any.whl:

Publisher: release-please.yml on triplate/triplate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page