Skip to main content

Python in, HTML out.

Project description

htmlclasses

Python in, HTML out.

There are templating engines making it possible to write code in HTML template files. However, I would very much prefer to be able to write Python that gets converted to HTML rather than write Python-like mini language engulfed in HTML.

Version

0.2.0

Goals

Generating valid HTML from pure Python code.

Non-goals

Features geared toward JavaScript.

  1. I find using 2 intertwined languages too cumbersome.
  2. JavaScript is heavily overused and misused. I don't want to add to the problem.

Installation

pip install htmlclasses

Developing

This project is managed with poetry: https://github.com/python-poetry/poetry

  1. git clone git@github.com:uigctaw/htmlclasses.git
  2. poetry install

Running tests

./check_all.sh

Examples

Hello World

This Python code:

from htmlclasses.htmlclasses import E


class html(E):

    class head:
        pass

    class body:

        class p:

            TEXT = 'Hello, world!'

Produces this HTML code:

<html>
    <head/>
    <body>
        <p>Hello, world!</p>
    </body>
</html>

Which renders as:

Hello, world!

Alternatives

https://pypi.org/project/html

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

htmlclasses-0.2.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

htmlclasses-0.2.0-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

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