Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages