Skip to main content

PyBlade

PyBlade is a lightweight, flexible, and efficient template engine for Python, inspired by Laravel's Blade syntax. It makes transitioning from Laravel to Django seamless by offering familiar features like components (inspired by Laravel Livewire) and a simple, intuitive syntax. Designed primarily for Django projects, PyBlade allows developers to create dynamic, interactive templates with ease, while maintaining robust security measures.

Roadmap

  • Basic template rendering with variable interpolation
  • Support for conditionals and loops
  • Template inheritance, partials, and slots
  • Integration with Django
  • Components similar to Laravel Livewire
  • Security measures
  • Full documentation

Features

  • Familiar Blade-Like Syntax: Intuitive @-based directives for conditions, loops, and variable interpolation.
  • Component Support: Fully functional component system inspired by Laravel Livewire, enabling developers to create reusable, dynamic components with real-time interactivity.
  • Easy Django Integration: A powerful alternative to Django's default templating engine, while maintaining seamless integration.
  • Lightweight and Fast: Optimized for performance and simplicity.
  • Security-Focused: Enhanced security features including:
    • Automatic escaping of variables
    • Safe expression evaluation
    • Protection against XSS attacks
    • CSRF protection for components
    • Secure attribute handling
  • Ideal for Laravel Developers: Designed to help Laravel developers easily understand and adapt to Django's ecosystem.

Documentation

Comprehensive documentation is available at pyblade.vercel.app, covering:

  • Getting started guide
  • Template syntax
  • Component system
  • Best practices
  • API reference

Installation

Install PyBlade via pip:

pip install pyblade

File Extension

PyBlade uses the standard .html file extension for templates, making it compatible with existing web development tools and workflows while maintaining familiar syntax highlighting and editor features.

IDE Support

Available Now

  • PyBlade IntelliSense in the VS Code marketplace with support of:
    • Syntax highlighting
    • Snippets
    • Auto-completion for directives and components

Coming Soon

  • JetBrains IDEs (PyCharm, WebStorm, etc.)
  • Sublime Text
  • Atom

Basic Usage

<!-- template.html -->
@extends('layouts.base')

@section('content')
    <h1>Welcome, {{ user.name }}!</h1>
    
    @if(posts)
        @for(post in posts)
            <article>
                <h2>{{ post.title }}</h2>
                <p>{{ post.content }}</p>
            </article>
        @endfor
    @else
        <p>No posts found.</p>
    @endif
    
    <!-- Interactive Component Example -->
    @component('like-button', post_id=post.id)
        <span>Like this post</span>
    @endcomponent
@endsection

Security

At PyBlade, we take security seriously. The template engine will automatically escape output unless explicitly marked as safe. This helps protect against Cross-Site Scripting (XSS) and ensures that user-generated content is handled securely. Additional features, such as CSRF token support and other security best practices, will be incorporated to ensure that your Django applications remain secure.

Contributing

Contributions are welcome! PyBlade is an open-source project, and we invite developers from both the Django and Laravel communities to collaborate. Please refer to the Contributing Guide for more information.

PyBlade is open source and welcomes contributions! Here's how you can help:

License

This project is licensed under the MIT License – see the LICENSE file for details.

Acknowledgements

  • Inspired by Laravel's Blade template engine and Livewire components.
  • Thanks to the Python, Django, and Laravel communities for their ongoing support of open-source projects.
  • Special thanks to Michael Dimchuk for graciously releasing the name PyBlade on PyPI for this project. Your kindness and support for the open-source community are truly appreciated!

Let's bring the power of Blade-like templating and Livewire-like interactivity to Django ! 🚀

Release files for PyBlade 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyBlade 0.2.0
File Size Uploaded
pyblade-0.2.0.tar.gz 90.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyBlade 0.2.0
File Interpreter ABI Platform
pyblade-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 205.2 kB

Release files / pyblade-0.2.0.tar.gz

Download URL pyblade-0.2.0.tar.gz
Size 90.1 kB
Tags Source
SHA-256 checksum
How to use checksums
51f032015c226e3ed8539f67c3af1c7d7f731d6dd95dee39dac04f6d1f92623f
BLAKE2b-256 checksum
How to use checksums
eb145fad69a428c1b10fa15f54f56dae109ba7f621c2b9f228108832af52d451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.2 Linux/6.12.32-amd64

Release files / pyblade-0.2.0-py3-none-any.whl

Download URL pyblade-0.2.0-py3-none-any.whl
Size 115.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ad368d1fddbf86067a6459f7c6882a9780e82750ef2a85e72d5da06c80fd701
BLAKE2b-256 checksum
How to use checksums
316233fa722ab27a3b713c8a16363dfbdddeaa406456f2bb614c58a72dc27b62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.2 Linux/6.12.32-amd64

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page