Skip to main content

Xylo

A powerful template engine with Python expression evaluation.

Installation

pip install xylo.py

Usage

from xylo import xylo

# Basic expressions
xylo("text $(1 + 5)")  # "text 6"

# Variables via context
xylo("Hello $(name)!", {"name": "World"})  # "Hello World!"

# Conditionals
xylo("$if(x > 5) Big $else Small $end", {"x": 10})  # " Big "

# Loops
xylo("$for(i in range(3)) $(i) $end")  # " 0  1  2 "

# Functions
xylo('$function(greet, name) Hello, $(name)! $end $call(greet, "World")')  # "  Hello, World! "

Features

  • Expressions: $(expression) - Evaluate and insert Python expressions
  • Exec: $exec(code) - Execute Python code without output
  • Conditionals: $if(cond) ... $elif(cond) ... $else ... $end
  • Loops: $for(var in iterable) ... $end, $while(cond) ... $end
  • Functions: $function(name, args) ... $end and $call(name, args)
  • Include: $include("file.sdf", key=value, ...) - Include and render another template
  • Import: $import("file.sdf", key=value, ...) - Import and render another template without the current context
  • Switch: $switch(expr) $case(val) ... $default ... $end
  • Error handling: $try ... $catch(e) ... $end, $raise(msg), $assert(cond)
  • Context managers: $with(expr as var) ... $end
  • Control flow: $break, $continue, $return

License

MIT

Metadata

Release files for xylo.py 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xylo.py 0.2.0
File Size Uploaded Provenance Actions
xylo_py-0.2.0.tar.gz 13.3 kB Without provenance Details for xylo_py-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xylo.py 0.2.0
File Interpreter ABI Platform Actions
xylo_py-0.2.0-py3-none-any.whl Python 3 none any Details for xylo_py-0.2.0-py3-none-any.whl

Total release size: 22.5 kB

Release files / xylo_py-0.2.0.tar.gz

Download URL xylo_py-0.2.0.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fd354cfcb9ef853eba25aca668e7524214e5e2342948a7580ad2ad84dccd96bf
BLAKE2b-256 checksum
How to use checksums
266d157af345315bdd67a646d0796665ad66780f55c4625fac78d5a212f4d947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / xylo_py-0.2.0-py3-none-any.whl

Download URL xylo_py-0.2.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
421d37ef1061cb4572ad2a71a64d6d512d85ebeb3b40f38005773251f976f96b
BLAKE2b-256 checksum
How to use checksums
c96540fd020651fbfaac7e921df61c1532f3682044b59b1d470f1b62bdc4c613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for xylo.py 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page