Skip to main content

A Vue.js-like templating engine using Jinja2 for Python

Project description

Py Level Fleet

A powerful Vue.js-like templating engine for Python using Jinja2. This package provides a familiar Vue.js syntax while leveraging the robust features of Jinja2.

Features

  • Vue.js-like template syntax with p- directives
  • Full Jinja2 template engine capabilities
  • Support for async rendering
  • Sandboxed environment for security
  • I18N support
  • BeautifulSoup4 for HTML parsing
  • Template caching for better performance

Installation

pip install py_level_fleet

Quick Start

from py_level_fleet import render_template

template = """
<div p-if="show">
    <p p-text="message"></p>
</div>
<ul>
    <li p-for="item in items" p-key="item.id">{{ item.name }}</li>
</ul>
"""

data = {
    'show': True,
    'message': 'Hello, World!',
    'items': [{'id': 1, 'name': 'Item 1'}, {'id': 2, 'name': 'Item 2'}]
}

output = render_template(template, data)
print(output)

Available Directives

  • p-if: Conditional rendering
  • p-else-if: Alternative condition
  • p-else: Fallback content
  • p-for: List rendering
  • p-key: Unique key for list items
  • p-bind: Dynamic attribute binding
  • p-text: Text content binding
  • p-html: HTML content binding
  • p-show: Conditional display
  • p-on: Event handling
  • p-model: Two-way data binding
  • p-pre: Skip compilation
  • p-once: Render once
  • p-cloak: Hide until compiled

Advanced Usage

Async Rendering

from py_level_fleet import VueJinjaEngine

engine = VueJinjaEngine(enable_async=True)
output = await engine.render_template_async(template, data)

Sandboxed Environment

from py_level_fleet import VueJinjaEngine

engine = VueJinjaEngine(sandboxed=True)
output = engine.render_template(template, data)

I18N Support

from py_level_fleet import VueJinjaEngine
from babel.support import Translations

translations = Translations.load('locale', ['en'])
engine = VueJinjaEngine(i18n_translations=translations)
output = engine.render_template(template, data)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Author

Vishnu Prasad - GitHub

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fleetvue-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fleetvue-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file fleetvue-0.1.1.tar.gz.

File metadata

  • Download URL: fleetvue-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fleetvue-0.1.1.tar.gz
Algorithm Hash digest
SHA256 816a052f3a7e3eee73ab80897ddc5c0261ab74210b95c8dd8e405f71f8b9be1d
MD5 5c473c16087f37cbfe9a0b854bcf27a0
BLAKE2b-256 99ca92ea502861c0da629787a31cf879e6f192badc7cba4dcab01c8b5b0069b3

See more details on using hashes here.

File details

Details for the file fleetvue-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fleetvue-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fleetvue-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbc947cdb486b5d17c43be71a70da6e357187fae0e1dc755e88d1c5ab883bd45
MD5 72ce23a98d298cdb0f3649e941f3c555
BLAKE2b-256 6714b5988fabd747f845301283ad0bc29e6afdcf6ad60bdbf338f731e3a4658a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page