mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-03 05:23:11 +00:00
21 lines
638 B
Python
21 lines
638 B
Python
def template(text, username, level=None):
|
|
"""
|
|
Replaces placeholders in the given text with actual values.
|
|
|
|
Args:
|
|
text (str): The template text containing placeholders.
|
|
username (str): The username to replace "{user}" placeholder.
|
|
level (int, optional): The level to replace "{level}" placeholder. Defaults to None.
|
|
|
|
Returns:
|
|
str: The formatted text.
|
|
"""
|
|
replacements = {
|
|
"{user}": username,
|
|
"{level}": str(level) if level is not None else ""
|
|
}
|
|
|
|
for placeholder, value in replacements.items():
|
|
text = text.replace(placeholder, value)
|
|
|
|
return text
|