generated from exteraGramPlugins/pluginBase
14 lines
331 B
Python
14 lines
331 B
Python
from textutil import normalize
|
|
|
|
|
|
class TemplateError(ValueError):
|
|
pass
|
|
|
|
|
|
def render(template: str, name: str) -> str:
|
|
normalized = normalize(name)
|
|
try:
|
|
return template.format(name=normalized)
|
|
except (KeyError, IndexError, ValueError):
|
|
raise TemplateError(f"unsupported placeholder in {template!r}")
|