rusty-tags


Namerusty-tags JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryHigh-performance HTML generation library with Rust-based Python extension
upload_time2025-07-29 12:48:18
maintainerNone
docs_urlNone
authorRustyTags Contributors
requires_python>=3.12
licenseMIT
keywords html web performance rust template
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RustyTags

⚠️ **Early Beta** - This library is in active development and APIs may change.

A high-performance HTML generation library that provides a Rust-based Python extension for building HTML/SVG tags. RustyTags offers significant speed improvements over pure Python HTML generation libraries through memory optimization and Rust-powered performance, now featuring FastHTML-style callable syntax for modern web development.

## What RustyTags Does

RustyTags generates HTML and SVG content programmatically with:
- **Speed**: Rust-powered performance with memory optimization and caching
- **Modern Syntax**: FastHTML-style callable chaining with minimal performance overhead
- **Type Safety**: Smart type conversion for Python objects (booleans, numbers, strings)
- **Framework Integration**: Supports `__html__`, `_repr_html_`, and `render()` methods
- **Advanced Features**: Custom tags, attribute mapping, complete HTML5/SVG support

## Quick Start

### Installation (Development)

```bash
# Clone and build from source
git clone <repository>
cd rustyTags
maturin develop

# Or build for release
maturin build --release
```

### Basic Usage

```python
from rusty_tags import Div, P, A, Html, Head, Body, Script, CustomTag, Svg, Circle, Text

# Simple HTML generation
content = Div(
    P("Hello World", cls="greeting"),
    A("Click here", href="https://example.com", target="_blank")
)
print(content)
# Output: <div><p class="greeting">Hello World</p><a href="https://example.com" target="_blank">Click here</a></div>

# FastHTML-style callable chaining (NEW!)
content = Div(cls="container")(
    P("Hello World", cls="greeting"),
    A("Click here", href="https://example.com")
)
print(content)
# Output: <div class="container"><p class="greeting">Hello World</p><a href="https://example.com">Click here</a></div>

# Flexible chaining patterns
link = A("Click me", href="/path")
wrapper = Div(cls="max-w-full")(link)
print(wrapper)
# Output: <div class="max-w-full"><a href="/path">Click me</a></div>

# Complete HTML document
page = Html(
    Head(
        Script("console.log('Hello');")
    ),
    Body(
        Div("Main content")
    ),
    lang="en"
)
print(page)
# Output: <!doctype html><html lang="en"><head><script>console.log('Hello');</script></head><body><div>Main content</div></body></html>

# Custom tags
custom = CustomTag("my-component", "Content", data_value="123")
print(custom)
# Output: <my-component data-value="123">Content</my-component>

# SVG graphics
svg_graphic = Svg(
    Circle(cx="50", cy="50", r="40", fill="blue"),
    Text("Hello SVG!", x="10", y="30", fill="white"),
    width="100", height="100"
)
print(svg_graphic)
# Output: <svg width="100" height="100"><circle cx="50" cy="50" r="40" fill="blue"></circle><text x="10" y="30" fill="white">Hello SVG!</text></svg>
```

## Features

### FastHTML-Style Callable API
- **Chainable Syntax**: Support for `Div(cls="container")(children...)` patterns
- **Flexible Composition**: Mix traditional and callable styles seamlessly
- **Performance Optimized**: Minimal overhead (6-8%) for callable functionality
- **Smart Returns**: Empty tags return callable builders, populated tags return HTML

### Performance Optimizations
- **Memory Pooling**: Thread-local string pools for efficient memory reuse
- **Lock-free Caching**: Global caches for attribute and tag name transformations
- **String Interning**: Pre-allocated common HTML strings
- **SIMD Ready**: Optimized for modern CPU instruction sets
- **Stack Allocation**: SmallVec for small collections to avoid heap allocation

### Smart Type Conversion
- **Automatic Type Handling**: Booleans, integers, floats, strings
- **Framework Integration**: `__html__()`, `_repr_html_()`, `render()` method support
- **Attribute Mapping**: `cls` → `class`, `_for` → `for`, etc.
- **Error Handling**: Clear error messages for unsupported types

### HTML Features
- **All Standard Tags**: Complete HTML5 tag set with optimized generation
- **Automatic DOCTYPE**: Html tag includes `<!doctype html>` 
- **Custom Tags**: Dynamic tag creation with any tag name
- **Attribute Processing**: Smart attribute key transformation and value conversion

## API Features

RustyTags provides clean, intuitive APIs with multiple styles:

```python
# Traditional style
from rusty_tags import Div, P
content = Div(P("Text", _class="highlight"), cls="container")

# FastHTML-style callable chaining
content = Div(cls="container")(P("Text", _class="highlight"))

# Mixed approach for complex layouts
page = Div(id="app")(
    Header(cls="top-nav")(
        Nav(A("Home", href="/"), A("About", href="/about"))
    ),
    Main(cls="content")(
        H1("Welcome"),
        P("Content here")
    )
)
```

## Performance

RustyTags significantly outperforms pure Python HTML generation:
- 3-10x faster than equivalent Python code
- Optimized memory usage with pooling and interning
- Aggressive compiler optimizations in release builds

## Development Status

🚧 **Early Beta**: While the core functionality is stable and tested, this library is still in early development. Breaking changes may occur in future versions. Production use is not recommended yet.

### Current Features
- ✅ All HTML5 tags implemented
- ✅ Complete SVG tag support
- ✅ FastHTML-style callable API
- ✅ Smart type conversion and attribute mapping
- ✅ Memory optimization and caching
- ✅ Custom tag support

### Planned Features
- 🔄 Template engine integration
- 🔄 Streaming HTML generation
- 🔄 PyPI package distribution

## Build from Source

```bash
# Development build
maturin develop

# Release build with optimizations
maturin build --release

# Run tests
python test_complex.py
python stress_test.py
```

## Requirements

- Python 3.8+
- Rust 1.70+
- Maturin for building

## License

[Add your license here]

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rusty-tags",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "html, web, performance, rust, template",
    "author": "RustyTags Contributors",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d1/b1/56beeaf9bc2a6aa728f0b0f40ac8dd74737cc51838e878772672bd98acef/rusty_tags-0.4.0.tar.gz",
    "platform": null,
    "description": "# RustyTags\n\n\u26a0\ufe0f **Early Beta** - This library is in active development and APIs may change.\n\nA high-performance HTML generation library that provides a Rust-based Python extension for building HTML/SVG tags. RustyTags offers significant speed improvements over pure Python HTML generation libraries through memory optimization and Rust-powered performance, now featuring FastHTML-style callable syntax for modern web development.\n\n## What RustyTags Does\n\nRustyTags generates HTML and SVG content programmatically with:\n- **Speed**: Rust-powered performance with memory optimization and caching\n- **Modern Syntax**: FastHTML-style callable chaining with minimal performance overhead\n- **Type Safety**: Smart type conversion for Python objects (booleans, numbers, strings)\n- **Framework Integration**: Supports `__html__`, `_repr_html_`, and `render()` methods\n- **Advanced Features**: Custom tags, attribute mapping, complete HTML5/SVG support\n\n## Quick Start\n\n### Installation (Development)\n\n```bash\n# Clone and build from source\ngit clone <repository>\ncd rustyTags\nmaturin develop\n\n# Or build for release\nmaturin build --release\n```\n\n### Basic Usage\n\n```python\nfrom rusty_tags import Div, P, A, Html, Head, Body, Script, CustomTag, Svg, Circle, Text\n\n# Simple HTML generation\ncontent = Div(\n    P(\"Hello World\", cls=\"greeting\"),\n    A(\"Click here\", href=\"https://example.com\", target=\"_blank\")\n)\nprint(content)\n# Output: <div><p class=\"greeting\">Hello World</p><a href=\"https://example.com\" target=\"_blank\">Click here</a></div>\n\n# FastHTML-style callable chaining (NEW!)\ncontent = Div(cls=\"container\")(\n    P(\"Hello World\", cls=\"greeting\"),\n    A(\"Click here\", href=\"https://example.com\")\n)\nprint(content)\n# Output: <div class=\"container\"><p class=\"greeting\">Hello World</p><a href=\"https://example.com\">Click here</a></div>\n\n# Flexible chaining patterns\nlink = A(\"Click me\", href=\"/path\")\nwrapper = Div(cls=\"max-w-full\")(link)\nprint(wrapper)\n# Output: <div class=\"max-w-full\"><a href=\"/path\">Click me</a></div>\n\n# Complete HTML document\npage = Html(\n    Head(\n        Script(\"console.log('Hello');\")\n    ),\n    Body(\n        Div(\"Main content\")\n    ),\n    lang=\"en\"\n)\nprint(page)\n# Output: <!doctype html><html lang=\"en\"><head><script>console.log('Hello');</script></head><body><div>Main content</div></body></html>\n\n# Custom tags\ncustom = CustomTag(\"my-component\", \"Content\", data_value=\"123\")\nprint(custom)\n# Output: <my-component data-value=\"123\">Content</my-component>\n\n# SVG graphics\nsvg_graphic = Svg(\n    Circle(cx=\"50\", cy=\"50\", r=\"40\", fill=\"blue\"),\n    Text(\"Hello SVG!\", x=\"10\", y=\"30\", fill=\"white\"),\n    width=\"100\", height=\"100\"\n)\nprint(svg_graphic)\n# Output: <svg width=\"100\" height=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\" fill=\"blue\"></circle><text x=\"10\" y=\"30\" fill=\"white\">Hello SVG!</text></svg>\n```\n\n## Features\n\n### FastHTML-Style Callable API\n- **Chainable Syntax**: Support for `Div(cls=\"container\")(children...)` patterns\n- **Flexible Composition**: Mix traditional and callable styles seamlessly\n- **Performance Optimized**: Minimal overhead (6-8%) for callable functionality\n- **Smart Returns**: Empty tags return callable builders, populated tags return HTML\n\n### Performance Optimizations\n- **Memory Pooling**: Thread-local string pools for efficient memory reuse\n- **Lock-free Caching**: Global caches for attribute and tag name transformations\n- **String Interning**: Pre-allocated common HTML strings\n- **SIMD Ready**: Optimized for modern CPU instruction sets\n- **Stack Allocation**: SmallVec for small collections to avoid heap allocation\n\n### Smart Type Conversion\n- **Automatic Type Handling**: Booleans, integers, floats, strings\n- **Framework Integration**: `__html__()`, `_repr_html_()`, `render()` method support\n- **Attribute Mapping**: `cls` \u2192 `class`, `_for` \u2192 `for`, etc.\n- **Error Handling**: Clear error messages for unsupported types\n\n### HTML Features\n- **All Standard Tags**: Complete HTML5 tag set with optimized generation\n- **Automatic DOCTYPE**: Html tag includes `<!doctype html>` \n- **Custom Tags**: Dynamic tag creation with any tag name\n- **Attribute Processing**: Smart attribute key transformation and value conversion\n\n## API Features\n\nRustyTags provides clean, intuitive APIs with multiple styles:\n\n```python\n# Traditional style\nfrom rusty_tags import Div, P\ncontent = Div(P(\"Text\", _class=\"highlight\"), cls=\"container\")\n\n# FastHTML-style callable chaining\ncontent = Div(cls=\"container\")(P(\"Text\", _class=\"highlight\"))\n\n# Mixed approach for complex layouts\npage = Div(id=\"app\")(\n    Header(cls=\"top-nav\")(\n        Nav(A(\"Home\", href=\"/\"), A(\"About\", href=\"/about\"))\n    ),\n    Main(cls=\"content\")(\n        H1(\"Welcome\"),\n        P(\"Content here\")\n    )\n)\n```\n\n## Performance\n\nRustyTags significantly outperforms pure Python HTML generation:\n- 3-10x faster than equivalent Python code\n- Optimized memory usage with pooling and interning\n- Aggressive compiler optimizations in release builds\n\n## Development Status\n\n\ud83d\udea7 **Early Beta**: While the core functionality is stable and tested, this library is still in early development. Breaking changes may occur in future versions. Production use is not recommended yet.\n\n### Current Features\n- \u2705 All HTML5 tags implemented\n- \u2705 Complete SVG tag support\n- \u2705 FastHTML-style callable API\n- \u2705 Smart type conversion and attribute mapping\n- \u2705 Memory optimization and caching\n- \u2705 Custom tag support\n\n### Planned Features\n- \ud83d\udd04 Template engine integration\n- \ud83d\udd04 Streaming HTML generation\n- \ud83d\udd04 PyPI package distribution\n\n## Build from Source\n\n```bash\n# Development build\nmaturin develop\n\n# Release build with optimizations\nmaturin build --release\n\n# Run tests\npython test_complex.py\npython stress_test.py\n```\n\n## Requirements\n\n- Python 3.8+\n- Rust 1.70+\n- Maturin for building\n\n## License\n\n[Add your license here]\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "High-performance HTML generation library with Rust-based Python extension",
    "version": "0.4.0",
    "project_urls": {
        "Homepage": "https://github.com/yourusername/rustyTags",
        "Issues": "https://github.com/yourusername/rustyTags/issues",
        "Repository": "https://github.com/yourusername/rustyTags"
    },
    "split_keywords": [
        "html",
        " web",
        " performance",
        " rust",
        " template"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ae35d644ee372cf9e6d6289ff10896609e884ce024e631459942faf1827b8868",
                "md5": "12bb4e498cb720761573b7f478c8439f",
                "sha256": "d5d5ac945ebb8452c272b884757737ddcbaed73829fe475c1c5421e7c89e10c2"
            },
            "downloads": -1,
            "filename": "rusty_tags-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl",
            "has_sig": false,
            "md5_digest": "12bb4e498cb720761573b7f478c8439f",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.12",
            "size": 1796201,
            "upload_time": "2025-07-29T12:48:16",
            "upload_time_iso_8601": "2025-07-29T12:48:16.287836Z",
            "url": "https://files.pythonhosted.org/packages/ae/35/d644ee372cf9e6d6289ff10896609e884ce024e631459942faf1827b8868/rusty_tags-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d1b156beeaf9bc2a6aa728f0b0f40ac8dd74737cc51838e878772672bd98acef",
                "md5": "9b67dd0ce399c2351703314645d4ea45",
                "sha256": "3dc74515a903f332b421bad168968bab2781edcea1460385d45f909b67f98612"
            },
            "downloads": -1,
            "filename": "rusty_tags-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9b67dd0ce399c2351703314645d4ea45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 58957,
            "upload_time": "2025-07-29T12:48:18",
            "upload_time_iso_8601": "2025-07-29T12:48:18.489406Z",
            "url": "https://files.pythonhosted.org/packages/d1/b1/56beeaf9bc2a6aa728f0b0f40ac8dd74737cc51838e878772672bd98acef/rusty_tags-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-29 12:48:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "rustyTags",
    "github_not_found": true,
    "lcname": "rusty-tags"
}
        
Elapsed time: 0.82138s