Metadata-Version: 2.4
Name: triplate
Version: 0.4.0
Summary: A templating engine for SPARQL queries with typed, injection-safe placeholders and loops
Project-URL: Homepage, https://triplate.dev
Project-URL: Repository, https://github.com/triplate/triplate
Project-URL: Issues, https://github.com/triplate/triplate/issues
Author: Triplate contributors
License-Expression: MIT
Keywords: injection-safe,query,rdf,sparql,template
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: rdflib>=6.0; extra == 'dev'
Provides-Extra: rdflib
Requires-Dist: rdflib>=6.0; extra == 'rdflib'
Description-Content-Type: text/markdown

# 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](https://triplate.dev).

```python
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](https://triplate.dev) for the full guide and specification.
