Skip to main content

AgentMark TemplateDX (Python)

Python implementation of the AgentMark templatedx transformer.

Installation

pip install agentmark-templatedx

Usage

This package transforms pre-parsed MDX AST trees. The AST is typically obtained by:

  • Parsing MDX with the TypeScript @agentmark-ai/templatedx package
  • Loading a pre-parsed AST from a JSON file
  • Receiving an AST from the AgentMark runtime
import asyncio
import json
from templatedx import TemplateDX

async def main():
    engine = TemplateDX()

    # Load a pre-parsed MDX AST (from TypeScript parser or JSON file)
    with open("template.ast.json") as f:
        ast = json.load(f)

    # Transform the AST with props
    result = await engine.transform(
        ast,
        props={"name": "Alice", "items": [1, 2, 3]}
    )

    print(result)

asyncio.run(main())

Custom Plugins

from templatedx import TagPlugin, PluginContext

class MyPlugin(TagPlugin):
    async def transform(self, props, children, context):
        # Transform children and return result
        transformer = context.create_node_transformer(context.scope)
        return await transformer.transform_children(children)

engine = TemplateDX()
engine.register_tag_plugin(MyPlugin(), ["MyTag"])

Custom Filters

engine = TemplateDX()
engine.register_filter("double", lambda x: x * 2)

Built-in Filters

  • capitalize(str) - Capitalize first character
  • upper(str) - Uppercase string
  • lower(str) - Lowercase string
  • truncate(str, length) - Truncate with ellipsis
  • abs(num) - Absolute value
  • join(arr, separator) - Join array elements
  • round(num, decimals) - Round number
  • replace(str, search, replacement) - Replace occurrences
  • urlencode(str) - URL encode string
  • dump(any) - JSON stringify

Built-in Tags

  • <If condition={...}> / <ElseIf condition={...}> / <Else> - Conditional rendering
  • <ForEach arr={...}>{(item, index) => ...}</ForEach> - Array iteration
  • <Raw>...</Raw> - Raw content passthrough

Metadata

Release files for agentmark-templatedx 0.3.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 agentmark-templatedx 0.3.0
File Size Uploaded Provenance Actions
agentmark_templatedx-0.3.0.tar.gz 47.1 kB Without provenance Details for agentmark_templatedx-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentmark-templatedx 0.3.0
File Interpreter ABI Platform Actions
agentmark_templatedx-0.3.0-py3-none-any.whl Python 3 none any Details for agentmark_templatedx-0.3.0-py3-none-any.whl

Total release size: 73.1 kB

Release files / agentmark_templatedx-0.3.0.tar.gz

Download URL agentmark_templatedx-0.3.0.tar.gz
Size 47.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d923f79dca3c786ee6ea4c6aede691bc5da708c29385ee4c2757ffb52cd93619
BLAKE2b-256 checksum
How to use checksums
a6b7c3da92794e545f04b017065b46d6ffff18f099641047e88e1a5fb35a0dbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / agentmark_templatedx-0.3.0-py3-none-any.whl

Download URL agentmark_templatedx-0.3.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cec5c3326b92718a4d8e6c70c41d022bb938c3ef68ea90fd62edaacb0b93eb8
BLAKE2b-256 checksum
How to use checksums
b31f819056ac5b04073436b656da637a03cf3f93ab3725b3e0fca13ab9b3d0e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for agentmark-templatedx 0.3.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