Skip to main content

A very simple too to generate html from python code

Project description

py3html

A very simple tool to generate html with python code.

Project Tabler
Author Özcan Yarımdünya
Documentation https://ozcanyarimdunya.github.io/py3html
Source code https://github.com/ozcanyarimdunya/py3html

py3html is a library that you can generate html by using same tree-structure python code.

Installation

pip install py3html

Usage

Basic usage

import py3html as ph

code = ph.P("Hello, World")

code.html()

Output

<p>Hello, World</p>

You can add more elements with attributes.

import py3html as ph

code = ph.Div(
    ph.H1("Welcome", attrs={"style": "color: red"}),
    ph.A("Click here!", attrs={"href": "example.com"}),
    ph.P(
        "Login ",
        ph.Small("to"),
        " continue !",
    ),
    attrs={"class": "container"}
)

code.html()

Output

<div class="container">
  <h1 style="color: red">Welcome</h1>
  <a href="example.com">Click here!</a>
  <p>Login <small>to</small> continue !</p>
</div>

Test

This project using pytest and pytest-cov.

make test

Documentation

Live preview

make serve-docs

Building

build-docs

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

py3html-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

py3html-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file py3html-0.1.0.tar.gz.

File metadata

  • Download URL: py3html-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.11 Darwin/20.6.0

File hashes

Hashes for py3html-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f5c82403c2c42abfbaa808fcce2a527a9de3d32d6b76fa3bd36c1e28cde1bd17
MD5 184532fed9f2ce8de92d5d0b78df8c7a
BLAKE2b-256 33a8e8194ebe235c31da45f3467b4d6345713b859a52044753ff1ea623db3abb

See more details on using hashes here.

File details

Details for the file py3html-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py3html-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.11 Darwin/20.6.0

File hashes

Hashes for py3html-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfa950b00cefdc70a088084a9c4eda5bd0f4c85bca02a015a8433722aafaddbb
MD5 530e2958b6fd32d6b866326830f9d612
BLAKE2b-256 1207b6bc4ff526bee1b7241d21fec4c00177f37c16676719a7a874369942c2a2

See more details on using hashes here.

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