Metadata-Version: 2.1
Name: tagged
Version: 0.0.1
Summary: Tagged templates for Python
Home-page: https://github.com/jviide/tagged
Author: Joachim Viide
Author-email: jviide@iki.fi
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown

# tagged

A Python version of JavaScript's tagged templates.

## Installation

```sh
$ pip3 install tagged
```

## Usage

```py
import re
from tagged import tag


@tag
def rex(strings, values):
    pattern = strings[0]
    for value, string in zip(values, strings[1:]):
        if isinstance(value, re.Pattern):
            value = value.pattern
        elif isinstance(value, str):
            value = re.escape(value)
        else:
            raise TypeError("expected re.Pattern or str")
        pattern += "(?:" + value + ")" + string
    return re.compile(pattern)


greeting = re.compile("Hello|Hi|Greetings")
name = "Python 3.7"
rex("{greeting}, {name}!")
# re.compile('(?:Hello|Hi|Greetings), (?:Python\\ 3\\.7)!')
```

## Development

### Running Tests

```sh
$ python3 -m unittest discover -s tests
```

## License

This library is licensed under the MIT license. See [./LICENSE](./LICENSE).


