Python Forum
Hypertag. New language for HTML templating w/ Django support - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Hypertag. New language for HTML templating w/ Django support (/thread-33206.html)



Hypertag. New language for HTML templating w/ Django support - mwojnars - Apr-06-2021

Hi,
A new language for document generation and HTML templating has been released. Inspired by indentation-based template languages (Slim, Haml, Shpaml), Hypertag (http://hypertag.io/) provides clean, readable syntax, and adds plenty of new features: native custom tags, DOM manipulation, Python-like imports, control blocks, expressions, and more. Multiple elements were carried over from the Python's syntax to ensure ease of use. An example Hypertag script:

ul
    li | Cat
    li | Dog
    li | Rabbit & Guinea pig
is rendered to:

<ul>
    <li>Cat</li>
    <li>Dog</li>
    <li>Rabbit &amp; Guinea pig</li>
</ul>
The example below contains a control block (for), chained tags (a, b, i) and an attribute (href):

h1 | Table of Contents
div
    for k in [1,2,3]:
        a href='#heading-{k}' : b : i | Heading no. $k
and is rendered to:

<h1>Table of Contents</h1>
<div>
    <a href="#heading-1"><b><i>Heading no. 1</i></b></a>
    <a href="#heading-2"><b><i>Heading no. 2</i></b></a>
    <a href="#heading-3"><b><i>Heading no. 3</i></b></a>
</div>
Hypertag can be called directly from Python code:

from hypertag import HyperHTML
html = HyperHTML().render(script)
or be plugged as a template backend into Django. Hypertag scripts can use all of Django's filter functions. Hypertag is a full-featured standalone language that is not limited to HTML alone and can generate different markups.

See the Quick Start and Language Reference for more info. Install from PyPI as "hypertag-lang".