Skip to main content

No project description provided

Project description

PyPI version License: MIT Downloads LinkedIn

template_filler

A Python package for filling template strings with combinations of provided variables. This tool is useful for generating multiple variations of text based on a single template and a set of possible variable values.

Installation

To install template_filler, use pip:

pip install template_filler

Usage

The fill_template function takes a template string and a list of dictionaries. Each dictionary specifies a variable name and a list of its possible values. The function returns a list of strings, where each string is a unique combination of the template filled with the provided variable values.

Basic Example

from template_filler import fill_template

template = "Hello, ${name}! Your age is ${age}."
vars_data = [
    {"name": ["Alice", "Bob"]},
    {"age": [30, 25]}
]

results = fill_template(template, vars_data)

# The 'results' list will contain:
# [
#   "Hello, Alice! Your age is 30.",
#   "Hello, Alice! Your age is 25.",
#   "Hello, Bob! Your age is 30.",
#   "Hello, Bob! Your age is 25."
# ]

for res in results:
    print(res)

Features

  • Combinatorial Filling: Generates all possible combinations of provided variable values.
  • String Templates: Utilizes Python's string.Template for straightforward placeholder syntax (e.g., ${variable_name}).
  • Type Flexibility: Handles various data types for variable values, converting them to strings for substitution.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

Author

  • Eugene Evstafev - LinkedIn

License

template_filler is licensed under the MIT License.

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

template_filler-2025.9.26945.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

template_filler-2025.9.26945-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file template_filler-2025.9.26945.tar.gz.

File metadata

  • Download URL: template_filler-2025.9.26945.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.11

File hashes

Hashes for template_filler-2025.9.26945.tar.gz
Algorithm Hash digest
SHA256 d9b1dbc3bd8a95693e02bc6a2d78f258972589b2216e775b164c8584284c1e14
MD5 bf16e8ef29489cf555e057512ffbf45f
BLAKE2b-256 33ed08d7565223fcbf105941074749baf4e518bc2ac0d730c9751c5a45d2c0f9

See more details on using hashes here.

File details

Details for the file template_filler-2025.9.26945-py3-none-any.whl.

File metadata

File hashes

Hashes for template_filler-2025.9.26945-py3-none-any.whl
Algorithm Hash digest
SHA256 c437ab2134b8922c357e49732a6eb66dc05adb176271df5d0e3868592d046c6e
MD5 b976cf503cb20befcb030ab4bd469c83
BLAKE2b-256 e90cd71860144aa4e2113e2024e3135ed5ed8edb503a40aea7f6a35e349fb023

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