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
Adaptive Cards 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()andjson(). - Supports
$root,$host, and$indexfor 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 Template
# Define a template
template_json = {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "${message}"
}
]
}
# Create a Template instance
template = Template(template_json)
# Expand the template with data
data = {
"$root": {
"message": "Hello, Adaptive Cards!"
}
}
card = template.expand(data)
# Pretty-print the card
print(json.dumps(card, indent=2))
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Write tests for your changes.
- Commit your changes and push the branch.
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adaptive_cards_templating_py-0.1.3.tar.gz.
File metadata
- Download URL: adaptive_cards_templating_py-0.1.3.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
396dd66379e8a65a167e3036eef3334903c99a16df24ebdf7b6b0c7ae51f8097
|
|
| MD5 |
9900fdee63134faf6aabffe5d631b56c
|
|
| BLAKE2b-256 |
79efbfa099f48f62aa726a9057893be7beaa175c91b7c2a4f61e75a8f3039b90
|
File details
Details for the file adaptive_cards_templating_py-0.1.3-py3-none-any.whl.
File metadata
- Download URL: adaptive_cards_templating_py-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bd48a1096b951985f6f31cc99cfb9a7068bccabb61793bef8592d3699d82790
|
|
| MD5 |
0b16f7951b0166f9e4f572337fdb7e18
|
|
| BLAKE2b-256 |
7478e19cc4881bad4d29fe4d673f9f65f61a1d7dbe086a7d9bc35f79c1d69635
|