Metadata-Version: 2.4
Name: yonlj-purepy
Version: 1.0.2
Summary: A Python templating engine inspired by ReactJS functional components
Project-URL: Homepage, https://github.com/YonLJ/purepy
Project-URL: Documentation, https://github.com/YonLJ/purepy#readme
Project-URL: Repository, https://github.com/YonLJ/purepy.git
Project-URL: Bug Tracker, https://github.com/YonLJ/purepy/issues
Author-email: YonLJ <istintin@outlook.com>
License-Expression: MIT
License-File: LICENSE
Keywords: component,frontend,functional-components,html,react,svg,template-engine,templating,web,xml
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Topic :: Text Processing :: Markup :: XML
Requires-Python: >=3.8
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=6.0; extra == 'dev'
Description-Content-Type: text/markdown

# Purepy

Purepy is a Python templating engine inspired by ReactJS functional components.

## Why use Purepy?

To enjoy pure Python programming.

In traditional approaches, mixing HTML code, Python code, and other template syntax in the view layer can be frustrating for developers.

However, with Purepy:
+ Everything is 100% native Python code.
+ Encapsulate components to eliminate repetitive HTML code.
+ The syntax closely resembles HTML.

## Documentation

Full documentation is available at https://yonlj.github.io/purepy/

## Install

```bash
pip install yonlj-purepy
```

## Basic usage

Here is a simple example that will show how to use `Purepy`:

```python
from pure.html import div, a

div(
    'Hello ',
    a('Python').href('https://www.python.org')
).class_name('container').style('background: #fff;').data_key('primary').to_print()
```

The above code will output:

```html
<div class="container" style="background: #fff;" data-key="primary">Hello <a href="https://www.python.org">Python</a></div>
```

## Component

You can use Purepy to encapsulate repeated code snippets into a functional component, which looks a lot like a React functional component:

```python
from pure.html import div, h2, p, a

# Function component
def Card(props):
    title = props.get('title', '')
    content = props.get('content', '')
    link = props.get('link', '#')

    return div(
        h2(title).class_name('card-title'),
        p(content).class_name('card-content'),
        a('Read more').href(link).class_name('card-link')
    ).class_name('card')

# Usage
Card({
    'title': 'Welcome to Purepy',
    'content': 'A Python templating engine inspired by React',
    'link': 'https://github.com/YonLJ/purepy'
}).to_print()
```

## Features

- **Pure Python**: Everything is 100% native Python code
- **Component-based**: Create reusable components like React
- **HTML-like syntax**: Familiar syntax for web developers
- **Type hints support**: Full type hints for better IDE support
- **Zero dependencies**: No external dependencies required
- **SVG support**: Built-in SVG element support
- **Lightweight**: Small footprint and fast performance

## Examples

For more usage examples see [here](https://github.com/YonLJ/purepy/tree/master/examples).

## Development

### Setup development environment

```bash
git clone https://github.com/YonLJ/purepy.git
cd purepy
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
```

### Run tests

```bash
pytest
```

### Code formatting

```bash
black pure tests
```

## License

MIT © YonLJ
