Skip to content

eeemoon/emplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pypi python codecov

emplace

Modern and easy way to handle placeholders.

This package allows you to define text placeholders and process them dynamically. It's like str.format(), but gives you much more flexibility.

Features

  • Regular Expressions to find placeholders.
  • Custom delimiters (%var%, {var}, ${var} etc.).
  • Modern API using asyncio and decorators.
  • Nested placeholders ({greet_{name}}).
  • Type safety using annotations.
  • No additional dependencies.

Installation

To install this module, run the following command:

pip install emplace

Usage

Example of creating a formatter with single placeholder.

from emplace import Formatter, placeholder

class MyFormatter(Formatter):
    @placeholder(r"upper_(?P<text>.*)")
    def upper_ph(self, text: str) -> str:
        return text.upper()
    
formatter = MyFormatter()
result = await formatter.format("Hello, {upper_world}!")
print(result) # Hello, WORLD!

Examples

You can check out more examples here.

About

Modern and easy way to handle placeholders.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages