Skip to main content

This library largely implements the JSON-to-JSON Adaptive Cards Template language for Python. Most features are supported, except for the Adaptive expressions prebuilt functions.

Project description

AdaptiveCards Templating for Python

This library largely implements the JSON-to-JSON Adaptive Cards Template language for Python. It allows you to dynamically expand Adaptive Card templates using data and host-specific information.

Features

  • Supports most standard features of the Adaptive Cards Template language.
  • Inline data expansion with $data.
  • Conditional rendering with $when.
  • Expression evaluation using ${} syntax.
  • Custom functions like if() and json().
  • Supports $root, $host, and $index for advanced templating.

Currently unsupported

  • Adaptive expressions prebuilt functions.

Installation

To install the package, use:

pip install adaptive-cards-templating-py

Usage

Here's a quick example of how to use the library:

import json
from adaptive_cards_templating_py import AdaptiveCardsTemplate

# Define a template
template_json = {
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "text": "${message}"
        }
    ]
}

# Create a Template instance
template = AdaptiveCardsTemplate(template_json)

# Expand the template with data
data = {
    "message": "Hello, Adaptive Cards!"
}
card = template.expand(data)

# Pretty-print the card
print(json.dumps(card, indent=2))

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Write tests for your changes.
  4. Commit your changes and push the branch.
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

adaptive_cards_templating_py-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

adaptive_cards_templating_py-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file adaptive_cards_templating_py-0.1.0.tar.gz.

File metadata

File hashes

Hashes for adaptive_cards_templating_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c92369bb363f3b9e401dd30afde3a39ec5375a2afc45e4a8a8a8cc7c7f37ab71
MD5 93d866350b95984fc2957e3c962a9681
BLAKE2b-256 7eba2e7243c049e3d261f4e901b08e5dffc02d9c617b53a80d76daef5e4be0bf

See more details on using hashes here.

File details

Details for the file adaptive_cards_templating_py-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for adaptive_cards_templating_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 503b0aecaad9f9d91bcc26bfd424f1a703cd0edc7f8a36e7911333e4b631063d
MD5 b649bae2c51cc79dff9af35c3d0477d3
BLAKE2b-256 1c19b7c6dd41b2f1348ac956f1c537a26f983b183765fe2a1d23d6edfa2b083d

See more details on using hashes here.

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